其他分享
首页 > 其他分享> > $bus

$bus

作者:互联网

main.ts
Vue.prototype.$bus = new Vue()

xxx.vue
import CombinedVueInstance from 'vue'
export default class XXX extends Vue {
  $bus!: CombinedVueInstance
  emitHandle() {
    this.$bus.$emit('test', 'hello')
  }
}

yyy.vue
import CombinedVueInstance from 'vue'
export default class YYY extends Vue {
  $bus!: CombinedVueInstance
  mounted() {
    this.$bus.$on('test', (msg) => {
       console.log(msg)
    })
  }
}

标签:Vue,bus,vue,export,CombinedVueInstance,extends
来源: https://www.cnblogs.com/Lilc20201212/p/16398206.html