Vue组件基础用法详解

2020-06-16 06:46:28易采站长站整理

doTheThing(){
this.message++;
}
}
})
</script>

可以使用 .native 修饰 v-on指令即可


<div id="example">
<my-component @click.native="doTheThing"></my-component>
<p>{{message}}</p>
</div>
<script>
Vue.component('my-component', {
template: '<button>按钮</button>',
})
new Vue({
el: '#example',
data:{
message:0
},
methods:{
doTheThing(){
this.message++;
}
}
})

更多关于Vue组件的使用方法请点击下面的相关链接