console
Vue.prototype.bus = new Vue()
Vue.component('child', {
data: function() {
return {
msg: this.content
}
},
props: {
content: String
},
template: '<div @click="handleChangeMsg">{{msg}}</div>',
methods: {
handleChangeMsg: function() {
this.bus.$emit('change', this.msg)
}
},
mounted: function() {
var _this = this
this.bus.$on('change', function(msg) {
_this.msg = msg
})
}
})
const vm = new Vue({
el: '#app'
})
<div id="app">
<child content="CalDey"></child>
<child content="Thomas"></child>
</div>
body {
font-size: 32px
}