vue todoList

cnpm install -g vue -cli

代码格式很重要,例如

msg: 'to do list',// msg: after need a space  ,前不能有空格,逗号后要有一个空格
items: [{text: '123'}, {text: '123'}]

这是 ESLint,用来规范代码风格的。不想要就在 webpack.config.js 中去掉eslint-loader

localStorage存储List

localStorage.setItem('name',1)
localStorage.getItem('name')//1

导入组件./store.js

import Store from './store'

需要同步更新

components:[Store]

然后使用watch来更新状态

watch: {
    items: {
      handler: function (val, oldVal) {
        Store.save(val)
        console.log(val, oldVal)//val是此次更新的值,oldVal是更新完后的数组
      },
      deep: true 
    }
  }

deep为true的时候,更改isFinished属性的时候都会改变localStorage,
为false,则不会修改

posted @ 2017-05-09 20:52  慕迪亚  阅读(81)  评论(0)    收藏  举报
你的浏览器不支持canvas