A event bus for Vue.js, support both Vue 1.0 and 2.0. See Vue documentation for more detail.
Installation
You can install it via yarn or npm.
$ yarn add vue-bus
$ npm install vue-bus --save
And it's available on jsdelivr or unpkg.
<!-- development version --> <!-- production version -->
When used with a module system, you must explicitly install the bus via Vue.use():
;; Vue;
You don't need to do this when using global script tags.
Usage
Listen and clean
// ... { this$bus; this$bus;} { this$bus;}methods: { thistodos; }
Trigger
// ...methods: { this$bus; this$bus; thisnewTodoText = ''; }
Another way to use vue-bus
// xxx.js; Vuebus;
Note: on
once
off
emit
are aliases for $on
$once
$off
$emit
. See the API for more detail.