标签:
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="robots" content="noindex, nofollow"> <meta name="googlebot" content="noindex, nofollow"> <style type="text/css"> </style> <title></title> <script type=‘text/javascript‘>//<![CDATA[ window.onload=function(){ new Vue({ el: ‘#app‘, data: { newTodo: ‘‘, todos: [ { text: ‘Add some todos‘ } ] }, methods: { addTodo: function () { var text = this.newTodo.trim() if (text) { this.todos.push({ text: text }) this.newTodo = ‘‘ } }, removeTodo: function (index) { this.todos.splice(index, 1) } } }) }//]]> </script> </head> <body> <script src="https://cdn.jsdelivr.net/vue/latest/vue.js"></script> <div id="app"> <input v-model="newTodo" v-on:keyup.enter="addTodo"> <ul> <li v-for="todo in todos"> <span>{{ todo.text }}</span> <button v-on:click="removeTodo($index)">X</button> </li> </ul> </div> </body> </html>
参考:
http://www.runoob.com/w3cnote/vue-js-quickstart.html
标签:
原文地址:http://www.cnblogs.com/super-d2/p/5562118.html