码迷,mamicode.com
首页 > 其他好文 > 详细

vue简单使用

时间:2016-06-05 23:21:54      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

<!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

vue简单使用

标签:

原文地址:http://www.cnblogs.com/super-d2/p/5562118.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!