setLocalStorgae to setLocalStorage

setLocalStorgae  to setLocalStorage
This commit is contained in:
rongxingsun 2018-07-30 09:01:01 +08:00 committed by GitHub
parent cd6b2a27b9
commit 2dd4878032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -72,7 +72,7 @@ export default {
} }
}, },
methods: { methods: {
setLocalStorgae() { setLocalStorage() {
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(this.todos)) window.localStorage.setItem(STORAGE_KEY, JSON.stringify(this.todos))
}, },
addTodo(e) { addTodo(e) {
@ -82,30 +82,30 @@ export default {
text, text,
done: false done: false
}) })
this.setLocalStorgae() this.setLocalStorage()
} }
e.target.value = '' e.target.value = ''
}, },
toggleTodo(val) { toggleTodo(val) {
val.done = !val.done val.done = !val.done
this.setLocalStorgae() this.setLocalStorage()
}, },
deleteTodo(todo) { deleteTodo(todo) {
this.todos.splice(this.todos.indexOf(todo), 1) this.todos.splice(this.todos.indexOf(todo), 1)
this.setLocalStorgae() this.setLocalStorage()
}, },
editTodo({ todo, value }) { editTodo({ todo, value }) {
todo.text = value todo.text = value
this.setLocalStorgae() this.setLocalStorage()
}, },
clearCompleted() { clearCompleted() {
this.todos = this.todos.filter(todo => !todo.done) this.todos = this.todos.filter(todo => !todo.done)
this.setLocalStorgae() this.setLocalStorage()
}, },
toggleAll({ done }) { toggleAll({ done }) {
this.todos.forEach(todo => { this.todos.forEach(todo => {
todo.done = done todo.done = done
this.setLocalStorgae() this.setLocalStorage()
}) })
} }
}, },