代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../../lib/vue-2.6.11.js"></script>
<title>Document</title>
</head>
<body>
<div id="cal">
<div>
<ul>
<li v-for="item in movies">{{item}}</li>
</ul>
</div>
<div>当前计数:{{couter}}</div>
<button v-on:click="couter++">+</button>
<button v-on:click="sub">-</button>
</div>
<script>
var calCalss = new Vue({
el: "#cal",
data: {
couter: 0,
movies: ["星际穿越", "大话西游", "海王"]
},
methods:{
sub: function(){
this.couter--;
}
}
});
</script>
</body>
</html>
页面效果
1、v-for: 循环指令
2、v-on: 监听事件
3、el : 绑定vue的模块
4、data: vue管理的数据
5、methods:方法