Skip to content

hw0k/vuevent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vuevent

A Vue.js Plugin which helps to use EventBus easily.

Installation

CommonJS:

$ npm i --save vuevent

And in your entry file:

import Vue from 'vue'
import Vuevent from 'vuevent'

Vue.use(Vuevent)

Usage:

This plugin binds a New Vue instance as a Global EventBus.

You can use like this:

// Sender Component
export default {
  methods: {
    this.$vuevent.$emit('event', 'hello world!')
  }
}

// Receiver Component
export default {
  mounted() {
    this.$vuevent.$on('event', args => {
      alert(args)
    })
  }
}