| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | <h2>{{num}}</h2><!-- 不需要传参的时候可以省略 方法的括号() -->
 <button v-on:click="add" type="button">+</button>
 <!-- 简写 -->
 <button @click="sub" type="button">-</button>
 
 data: {
 num: 0
 },
 methods: {
 add(){
 this.num++;
 },
 sub(){
 this.num--;
 }
 }
 
 |