Vuejs-01 todolist 만들기

2857 단어


<span style="color:#000000;">
import Store from </span>'./store'<span style="color:#000000;">
console.log(Store)
export </span><span style="color:#0000ff;">default</span><span style="color:#000000;"> {
  data:</span><span style="color:#0000ff;">function</span><span style="color:#000000;">() {
     </span><span style="color:#0000ff;">return</span><span style="color:#000000;"> {
       title: </span>'this is a todo list'<span style="color:#000000;">,
       items: (Store.fetch() </span>== <span style="color:#0000ff;">null</span> ?<span style="color:#000000;"> []: Store.fetch()),
       newItem:</span>''<span style="color:#000000;">
     }
  },
  watch:{
    items: {
       handler:</span><span style="color:#0000ff;">function</span><span style="color:#000000;">(items) {
          Store.save(items)
       },
       deep:</span><span style="color:#0000ff;">true</span><span style="color:#000000;">
    }
  },
  methods:{
    toggleFinish: </span><span style="color:#0000ff;">function</span><span style="color:#000000;">(item) {
      item.isFinished </span>= !<span style="color:#000000;">item.isFinished;
      console.log(item)
    },
    addNew: </span><span style="color:#0000ff;">function</span><span style="color:#000000;">() {
       </span><span style="color:#0000ff;">this</span><span style="color:#000000;">.items.push({
        label: </span><span style="color:#0000ff;">this</span><span style="color:#000000;">.newItem,
        isFinished: </span><span style="color:#0000ff;">false</span><span style="color:#000000;">
       }),
       </span><span style="color:#0000ff;">this</span>.newItem = ''<span style="color:#000000;">
    }

  }

}
</span>


 
전재 대상:https://www.cnblogs.com/xrwm97/p/6243175.html

좋은 웹페이지 즐겨찾기