2.0.1 • Published 5 years ago

vue-option-events v2.0.1

Weekly downloads
552
License
MIT
Repository
github
Last release
5 years ago

vue-option-events

npm bundle size npm downloads license

github travis coverage

Bring Vue.js 1 events option and $emit to Vue.js 2.

Install

npm install vue-option-events --save

Basic Usage

Install plugin

import Vue from 'vue';
import vueOptionEvents from 'vue-option-events';

Vue.use(vueOptionEvents);

Set events option

Component A

new Vue({
  methods: {
    show(hiMessage) {
      console.log(hiMessage);
    }
  },

  events: {
    hello(helloMessage) {
      console.log(helloMessage);
    },
    hi: 'show'
  }
});

Component B

new Vue({
  methods: {
    send() {
      this.$emit('hello', 'world');
      this.$emit('hi', 'world');
    }
  }
});

Use as global event bus

new Vue({
  methods: {
    send() {
      this.$event.$emit('hello', 'world');
    }
  }
});

Emit events from any where

import eventBus from 'vue-option-events';

eventBus.$emit('hello', 'world');

Options

Vue.use(vueOptionEvents, {
  keepAlive: false
});
2.0.1

5 years ago

2.0.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.7

6 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago