Added Vuex

This commit is contained in:
2019-05-29 01:49:49 +03:00
parent 1b625609bd
commit 6b98bc880f
20 changed files with 176 additions and 86 deletions

View File

@@ -1,14 +1,12 @@
<template>
<div id="app">
<Header />
<AddTodo v-on:add-todo="addTodo"/>
<Todos v-bind:todos="todos" v-on:del-todo="deleteTodo" />
<AddTodo />
<Todos />
</div>
</template>
<script>
import uuid from 'uuid'
import Header from "./components/layout/Header";
import Todos from "./components/Todos";
import AddTodo from "./components/AddTodo";
@@ -20,34 +18,6 @@ export default {
Todos,
AddTodo
},
data() {
return {
todos: [
{
id: uuid.v4(),
name: "Что-то, что я собираюсь сделать",
completed: false
},
{
id: uuid.v4(),
name: "Что-то, что я уже сделал",
completed: true
}
]
}
},
methods: {
deleteTodo(id) {
this.todos = this.todos.filter(todo => todo.id !== id);
},
addTodo(n) {
(n !== '' & n !== ' ') && this.todos.push({
id: uuid.v4(),
name: n,
completed: false
})
}
}
}
</script>
@@ -58,7 +28,6 @@ export default {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: ;
margin-top: 50px;
}
</style>