Event Bus & Event Emitter

时间:2021-01-17 08:58:27

Event Bus & Event Emitter

Event Bus

https://code.luasoftware.com/tutorials/vuejs/parent-call-child-component-method/

webpack & bug

Event Bus & Event Emitter


// import EventEmitter from "./event-emitter"; import Vue from 'vue';
// import * as VueEventBus from 'vue';
// import * as VueEventBus from 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.esm.browser.js'; const log = console.log;

Event Bus & Event Emitter

.$emit & .on

OK ???

import Vue from 'vue';
// import * as VueEventBus from 'vue';
// import * as VueEventBus from 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.esm.browser.js'; // A
// this.svgEventBus.fire(`update-status-data`);
this.svgEventBus.$emit(`update-status-data`); // B
// this.svgEventBus.on(`update-status-data`, this.updateSVGData);
this.svgEventBus.$on(`update-status-data`, this.updateSVGData);

Event Emitter

https://repl.it/@xgqfrms/EventEmitter-class

OK

fire & on

import EventEmitter from "./event-emitter";

// import Vue from 'vue';
// import * as VueEventBus from 'vue';
// import * as VueEventBus from 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.esm.browser.js'; const log = console.log; data() {
return {
// Event Emitter
svgEventBus: new EventEmitter(),
// svgEventBus: new VueEventBus(),
// svgEventBus: new Vue(),
storeData: {
status: {
r: 0,
x: 0,
y: 0,
w: 0,
h: 0,
},
},
templateData: {},
seatData: {},
seatMap: "",
};
},

Event Bus & Event Emitter



refs


Event Bus & Event Emitter

xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!