vue | $bus

在組件1中調用組件2中的方法

組件1:

this.$bus.$emit("change_event", "參數")
 
組件2:
mounted () {
    this.$bus.$on('change_event', (參數) => {
    // 需要調用的方法
      this.init() 
    })
 }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章