Vue 中Bus使用


  • 使用:兄弟組件之間傳值;
  • 安裝: npm install vue-bus
  • 在main.js 中引入vuebus:
import Vue from 'vue';
import VueBus from 'vue-bus';

Vue.use(VueBus);

 

在組件中使用 

觸發事件:

this.$bus.emit("onslected",params)
應對事件:
mounted:function(){
this.$bus.on("onslected",function(){

});
},
destroyed:function(){
this.$bus.off("onslected");
}
 



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM