mutations.js 432 B

123456789101112131415161718192021
  1. export const STORAGE_KEY = 'todos-vuejs'
  2. // for testing
  3. if (navigator.userAgent.indexOf('PhantomJS') > -1) {
  4. window.localStorage.clear()
  5. }
  6. export const mutations = {
  7. addTodo (state, todo) {
  8. state.todos.push(todo)
  9. },
  10. removeTodo (state, todo) {
  11. state.todos.splice(state.todos.indexOf(todo), 1)
  12. },
  13. editTodo (state, { todo, text = todo.text, done = todo.done }) {
  14. todo.text = text
  15. todo.done = done
  16. }
  17. }