A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/amejiarosario/vue-todo-app/commit/579da19 below:

vue watchers and localstorage · amejiarosario/vue-todo-app@579da19 · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+12

-2

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+12

-2

lines changed Original file line number Diff line number Diff line change

@@ -1,8 +1,10 @@

1 +

const LOCAL_STORAGE_KEY = 'todo-app-vue';

2 + 1 3

const todoApp = new Vue({

2 4

el: '.todoapp',

3 5

data: {

4 6

title: 'Todos',

5 -

todos: [

7 +

todos: JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY)) || [

6 8

{ text: 'Learn JavaScript ES6+ goodies', isDone: true },

7 9

{ text: 'Learn Vue', isDone: false },

8 10

{ text: 'Build something awesome', isDone: false },

@@ -42,5 +44,13 @@ const todoApp = new Vue({

42 44

completedTodos() {

43 45

return this.todos.filter(t => t.isDone);

44 46

}

45 -

}

47 +

},

48 +

watch: {

49 +

todos: {

50 +

deep: true,

51 +

handler(newValue) {

52 +

localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(newValue));

53 +

}

54 +

}

55 +

},

46 56

});

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4