感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<div id="div_col">
<p>自定义事件</p>
<p>{{total}}</p>
<example1 v-on:incretment="incretmentTotal" value="点击"></example1>
</div>
xxxxxxxxxx
Vue.component('example1', {
props: ['value'],
template: '<button v-on:click="incrementHanlder">{{value}}</button>',
// data: function () {
// return {
// count: 0
// }
// },
methods: {
incrementHanlder: function () {
// this.count += 1
this.$emit('incretment')
}
})
new Vue({
el: '#div_col',
data: {
total: 0
},
incretmentTotal: function () {
this.total += 1
输入 CSS 代码……