vue数据操作 num加减点击事件
<div id="app"><button v-on:click="add(10)">click me</button><button v-on:click="remove(5)">click me</button
·
<div id="app"> <button v-on:click="add(10)">click me</button> <button v-on:click="remove(5)">click me</button> <button v-on:click="num++">click me</button> <button v-on:click="num--">click me</button> <span>{{num}}</span> </div> <script src="js/vue.js"></script> <script> new Vue({ el: '#app', data: { num:0, message: '6', data: { name: '', gender: '', interest: [], identity: '' }, selected: 'A', options: [ { text: 'One', value: 'A' }, { text: 'Two', value: 'B' }, { text: 'Three', value: 'C' } ] }, methods:{ add:function (inc){ this.num += inc; }, remove:function (dec){ this.num -= dec; }, } }) </script>
更多推荐
已为社区贡献11条内容
所有评论(0)