代码如下:<div id="counter-event-example"> <p>{{ total }}</p> <button-counter v-on:click="incrementTotal"></button-counter> <button-counter v-on:click="incrementTotal"></button-counter></div><script>Vue.component('button-counter', { template: '<button >{{ counter }}</button>', data: function () { return { counter: 0 }; }}); new Vue({el: '#counter-event-example', data: { total: 0 }, methods: { incrementTotal: function () { this.total += 1; } }});</script>为什么button-counter添加的click事件不能调用父元素的methods里面的方法呢?
添加回答
举报
0/150
提交
取消