We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eab0467 commit 0a2c31eCopy full SHA for 0a2c31e
1 file changed
src/app.vue
@@ -27,6 +27,8 @@
27
28
<script>
29
30
+var STORE_KEY = "todos";
31
+
32
var filters = {
33
all: (todos) => todos,
34
active: (todos) => todos.filter(todo => !todo.completed),
@@ -35,11 +37,18 @@ var filters = {
35
37
36
38
export default {
39
data: {
- todos: [],
40
+ todos: JSON.parse(localStorage.getItem(STORE_KEY) || '[]'),
41
input: '',
42
filter: 'all'
43
},
44
45
+ watch: {
46
+ todos: {
47
+ handler: (todos) => localStorage.setItem(STORE_KEY, JSON.stringify(todos)),
48
+ deep: true
49
+ }
50
+ },
51
52
computed: {
53
remaining() { return filters.active(this.todos).length; },
54
filtered() { return filters[this.filter](this.todos); }
0 commit comments