Answers for "vue js getter"

2

vue js getter

const store = new Vuex.Store({
  state: {
    todos: [
      { id: 1, text: '...', done: true },
      { id: 2, text: '...', done: false }
    ]
  },
  getters: {
    doneTodos: state => {
      return state.todos.filter(todo => todo.done)
    }
  }
});

console.log(store.state.getters.doneTodos);
// -> [{ id: 1, text: '...', done: true }]
Posted by: Guest on July-26-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language