|
@@ -46,15 +46,8 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import store from '../store'
|
|
|
|
import Todo from './Todo.vue'
|
|
import Todo from './Todo.vue'
|
|
|
|
|
|
-const {
|
|
|
|
- addTodo,
|
|
|
|
- toggleAll,
|
|
|
|
- clearCompleted
|
|
|
|
-} = store.actions
|
|
|
|
-
|
|
|
|
const filters = {
|
|
const filters = {
|
|
all: (todos) => todos,
|
|
all: (todos) => todos,
|
|
active: (todos) => todos.filter(todo => !todo.done),
|
|
active: (todos) => todos.filter(todo => !todo.done),
|
|
@@ -71,7 +64,7 @@ export default {
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
todos () {
|
|
todos () {
|
|
- return store.state.todos
|
|
|
|
|
|
+ return this.$store.state.todos
|
|
},
|
|
},
|
|
allChecked () {
|
|
allChecked () {
|
|
return this.todos.every(todo => todo.done)
|
|
return this.todos.every(todo => todo.done)
|
|
@@ -87,12 +80,16 @@ export default {
|
|
addTodo (e) {
|
|
addTodo (e) {
|
|
var text = e.target.value
|
|
var text = e.target.value
|
|
if (text.trim()) {
|
|
if (text.trim()) {
|
|
- addTodo(text)
|
|
|
|
|
|
+ this.$store.actions.addTodo(text)
|
|
}
|
|
}
|
|
e.target.value = ''
|
|
e.target.value = ''
|
|
},
|
|
},
|
|
- toggleAll,
|
|
|
|
- clearCompleted
|
|
|
|
|
|
+ toggleAll () {
|
|
|
|
+ this.$store.actions.toggleAll()
|
|
|
|
+ },
|
|
|
|
+ clearCompleted () {
|
|
|
|
+ this.$store.actions.clearCompleted()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|