fix(mixin): mixin support

pull/307/head
谭杨 3 years ago
parent 1678253d93
commit e1e444c7df

File diff suppressed because one or more lines are too long

@ -33,12 +33,14 @@ export default class VueSocketIO {
if (version >= 3) { if (version >= 3) {
Vue.config.globalProperties.$socket = this.io; Vue.config.globalProperties.$socket = this.io;
Vue.config.globalProperties.$vueSocketIo = this; Vue.config.globalProperties.$vueSocketIo = this;
Vue.mixin(Mixin(true));
} else { } else {
Vue.prototype.$socket = this.io; Vue.prototype.$socket = this.io;
Vue.prototype.$vueSocketIo = this; Vue.prototype.$vueSocketIo = this;
Vue.mixin(Mixin(false));
} }
Vue.mixin(Mixin);
Logger.info('Vue-Socket.io plugin enabled'); Logger.info('Vue-Socket.io plugin enabled');

@ -1,4 +1,4 @@
export default { export default (isVue3) => ({
/** /**
* Assign runtime callbacks * Assign runtime callbacks
@ -39,7 +39,7 @@ export default {
/** /**
* unsubscribe when component unmounting * unsubscribe when component unmounting
*/ */
beforeUnmount(){ [isVue3 ? 'beforeUnmount' : 'beforeDestroy'](){
if(this.$options.sockets){ if(this.$options.sockets){
@ -53,4 +53,4 @@ export default {
} }
} })
Loading…
Cancel
Save