1.0.1 • Published 6 years ago

dynamic-vue-bus v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

在Vue项目中使用EventBus拥有生命周期,不用再去手动销毁 参考文章:让在Vue中使用的EventBus也有生命周期 ##使用 npm install dynamic-vue-bus

import eventBus from 'dynamic-vue-bus'
Vue.use(eventBus)

##组件中使用

 created () {
   let text = Array(1000000).fill('xxx').join(',')
   this.$eventBus.$on('home-on', (...args) => {
     // todo something
   }, this) // 注意第三个参数要传this
 },
 mounted () {
   setTimeout(() => {
     this.$eventBus.$emit('home-on', '这是home $emit参数')
   }, 1000)
 }