Bring Vue.js 1 events option and $emit to Vue.js 2.
Installnpm install vue-option-events --save
Basic Usage Install plugin
Setimport Vue from 'vue';
import vueOptionEvents from 'vue-option-events';
Â
Vue.use(vueOptionEvents);
events
option
Component A
new Vue({
  methods: {
    show(hiMessage) {
      console.log(hiMessage);
    }
  },
Â
  events: {
    hello(helloMessage) {
      console.log(helloMessage);
    },
    hi: 'show'
  }
});
Component B
Use as global event busnew Vue({
  methods: {
    send() {
      this.$emit('hello', 'world');
      this.$emit('hi', 'world');
    }
  }
});
Emit events from any wherenew Vue({
  methods: {
    send() {
      this.$event.$emit('hello', 'world');
    }
  }
});
Optionsimport eventBus from 'vue-option-events';
Â
eventBus.$emit('hello', 'world');
Vue.use(vueOptionEvents, {
  keepAlive: false
});
keepAlive
enable if you want keep handling events on inactive keep-alive components, default false
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4