<div id="app">
<h2>当前计数:{{counter}}</h2>
<!-- <button v-on:click='counter++'>+</button>
<button v-on:click='counter--'>-</button> -->
<button v-on:click='add'>+</button>
<button @click='jian'>-</button>
</div>
<script>
// const aa=20;
const shuju = new Vue({
el: '#app',
data: {
counter: 0,
bb:30
},
methods:{//定义函数的
add:function(){
this.counter++;
console.log("执行了add",this.bb);//如果在这里this.aa 结果提示未定义
},
jian:function(){
this.counter--;
console.log("执行了jian");
}
},//在vue里面可以定义 N个函数
zidinyihanshu:function(){
console.log('自定义函数');
}
})