console
Vue.component('balance', {
template: '#balance-component-tpl',
methods: {
show_balance:function(data){
this.show=!this.show;
console.log('data:', data);
}
},
data: function(){
return {
show: false
}
}
});
Vue.component('show', {
template: '#show-componenet-tpl',
methods: {
on_click:function() {
this.$emit('show-balance',{a:1,b:2})
}
}
});
new Vue({
el: '#app'
});
<div id="app">
<balance>
</balance>
</div>
<template id="balance-component-tpl">
<div>
<show @show-balance = "show_balance"></show>
<div v-if="show">您的余额:8元</div>
</div>
</template>
<template id="show-componenet-tpl">
<button @click="on_click">显示余额</button >
</template>