#自定义事件使用
$on(eventName) 监听事件,使用 KaTeX parse error: Expected 'EOF', got '#' at position 28: …me) 触发事件 关键字: #̲emit(‘ic’)自定义事件名
component
methods
funciton
<div id="button-event">
<p>{{city}}</p>
<button-add v-on:ic="cqyb"></button-add>
<button-add v-on:ic="cqyb"></button-add>
</div>
<script>
Vue.component('button-add',{
template:'<button v-on:click="addcount">{{count}}</button>',
data:function(){
return{
count:0
}
},
methods:{
addcount:function(){
this.count+=1
this.$emit('ic')
}
}
}),
new Vue({
el:'#button-event',
data:{
city:1
},
methods:{
cqyb:function(){
this.city+=1
}
}
})
</script>