{"id":515,"date":"2020-02-26T17:01:28","date_gmt":"2020-02-26T09:01:28","guid":{"rendered":"https:\/\/blog.cqdefxxx.com\/?p=515"},"modified":"2020-02-26T17:01:28","modified_gmt":"2020-02-26T09:01:28","slug":"vue-%e5%88%97%e8%a1%a8%e6%b8%b2%e6%9f%93-todolist","status":"publish","type":"post","link":"https:\/\/blog.viter.top\/index.php\/2020\/02\/26\/vue-%e5%88%97%e8%a1%a8%e6%b8%b2%e6%9f%93-todolist\/","title":{"rendered":"Vue-\u5217\u8868\u6e32\u67d3-todolist"},"content":{"rendered":"<pre class=\"pure-highlightjs\"><code class=\"\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;meta charset=\"utf-8\"&gt;\n&lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"&gt;\n&lt;title&gt;Examples&lt;\/title&gt;\n&lt;meta name=\"description\" content=\"\"&gt;\n&lt;meta name=\"keywords\" content=\"\"&gt;\n&lt;link href=\"\" rel=\"stylesheet\"&gt;\n&lt;style&gt;\n    \n    .active{\n        \/*background-color: red;*\/\n        text-decoration: line-through;\n    }\n\n\n&lt;\/style&gt;\n&lt;script type=\"text\/javascript\" src=\"lib\/vue.js\"&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    \n   \t&lt;div id=\"box\"&gt;\n\n      &lt;input type=\"text\" v-model=\"text\"\/&gt;\n      &lt;button @click=\"handleAdd()\"&gt;add&lt;\/button&gt;\n   \t\t&lt;ul&gt;\n       &lt;li :class=\"data.isMarked?'active':''\" v-for=\"data,index in list\" @click=\"handleClick(index)\"&gt;\n         {{data.value}}\n         &lt;button @click=\"handleDelClick(index)\"&gt;del&lt;\/button&gt;\n        &lt;button @click=\"handleMarkClick(index)\"&gt;mark&lt;\/button&gt;\n\n       &lt;\/li&gt; \n      &lt;\/ul&gt;\n   \t&lt;\/div&gt;\n\n   &lt;script type=\"text\/javascript\"&gt;\n\n  \t\tvar vm = new Vue({\n        el:\"#box\",\n\n        data:{\n          list:[],\n          text:'',\n          current:0\n        },\n\n        methods:{\n          handleClick(index){\n            console.log(index);\n            this.current= index;\n          },\n          handleAdd(){\n            this.list.push({\n              value:this.text,\n              isMarked:false\n            });\n          },\n          handleDelClick(index){\n            this.list.splice(index,1)\n          },\n          handleMarkClick(index){\n            this.list[index].isMarked = !this.list[index].isMarked\n          }\n\n        }\n      })\n   \t  \n   &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset= &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[9,10],"_links":{"self":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/515"}],"collection":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/comments?post=515"}],"version-history":[{"count":0,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/515\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/media?parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/categories?post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/tags?post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}