File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 11var app = new Vue ( {
22
3+ // the root element that will be compiled
34 el : '#todoapp' ,
45
6+ // a custom directive to wait for the DOM to be updated
7+ // before focusing on the input field.
58 directives : {
69 'todo-focus' : function ( value ) {
710 if ( value ) {
@@ -11,6 +14,8 @@ var app = new Vue({
1114 }
1215 } ,
1316
17+ // the `created` lifecycle hook.
18+ // it will be called when the ViewModel instance is created.
1419 created : function ( ) {
1520 this . filters = {
1621 all : function ( todo ) { todo . completed ; return true } ,
@@ -26,8 +31,13 @@ var app = new Vue({
2631 } ) . length
2732 } ,
2833
34+ // data
2935 data : {
36+
37+ // fetch the saved todos from localStorage
3038 todos : todoStorage . fetch ( ) ,
39+
40+ // a computed property with custom getter/setter
3141 allDone : {
3242 $get : function ( ) {
3343 return this . remaining === 0
@@ -42,6 +52,8 @@ var app = new Vue({
4252 }
4353 } ,
4454
55+ // methods that implement data logic.
56+ // note there's no DOM manipulation here at all!
4557 methods : {
4658
4759 updateFilter : function ( ) {
You can’t perform that action at this time.
0 commit comments