Vueの非親子関係

1234 ワード




    
    Title


// Vue , ‘ ’ var bus=new Vue Vue.component('one',{ template:` <div> <h3> one</h3> <button @click="sendS"> two</button> </div> `, data:function(){ return{ msg:'hello word' } }, methods:{ sendS:function(){ // , bus.$emit('send',this.msg) } } }) Vue.component('two',{ template:` <div> <h3> two</h3> <a href="">{{mess}}</a> </div> `, data:function(){ return{ mess:'' } }, // this 。 bind , 。 mounted:function(){ bus.$on('send',msg=>{ this.mess=msg }) } }) new Vue({ el:'#itany' })