Let Vue.js support global events
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist release 1.0.5 Oct 12, 2018
src
.gitignore docs 添加中文README.zh-cn.md Oct 11, 2018
README.md feat 添加压缩后的版本,并且把默认导出改为压缩后的js Oct 12, 2018
README.zh-cn.md doc zh-cn add Oct 12, 2018
package.json

README.md

Vue Event Proxy

npm

Introduction

The Library that let Vue.js support global events, just 1.79kb after compression.

  1. Global events are implemented by adding a prefix
  2. Registered event will be removed when component is destroyed

Demo: CodeSandbox

install

$ npm install --save vue-event-proxy

Usage

Just add global: prefix to first argument of methods: $on, $emit, $once

import EventProxy from 'vue-event-proxy';
Vue.use(EventProxy);

this.$on('global:EVENT_NAME');
this.$once('global:EVENT_NAME');
this.$emit('global:EVENT_NAME');

More see: https://cn.vuejs.org/v2/api/#vm-on