You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A caveat to readme.md's vue demo is that if a module is reused more than once on the same page, vueInstance can be shared more than once. react won't have this problem because the reatc update is based on container, which is unique.
importVuefrom'vue/index';importAppfrom'./component/Hello.vue';letvueInstance=null;exportasyncfunctionbootstrap(){console.log('vue app bootstraped');}exportasyncfunctionmount(container,props){console.log('magic-microservices-component-vue mount >>> ',props);vueInstance=Vue.createApp({
...App,data(){returnprops;},}).mount(container);}exportasyncfunctionupdated(attrName,value){console.log('magic-microservices-component-vue update',attrName,' >>> ',value);vueInstance[attrName]=value;vueInstance.$forceUpdate();}exportasyncfunctionunmount(){console.log('vue app will unmount');}
hack:
import{createApp}from'vue';importAppfrom'./App.vue';/** * Multiple vue instances are identified by container as unique identifiers */constvueInstanceMap=newWeakMap();exportasyncfunctionmount(container: Element,props: any){constvueInstance=createApp({
...App,data(){returnprops;},}).mount(container);vueInstanceMap.set(container,vueInstance)}exportasyncfunctionupdated(attrName: string,value: any,container: Element,){constvueInstance=vueInstanceMap.get(container);vueInstance[attrName]=value;vueInstance.$forceUpdate();}exportfunctionunmount(magicInstance: any,container: any){constvueInstance=vueInstanceMap.get(container);vueInstance.unmount();}
The text was updated successfully, but these errors were encountered:
The problem:
A caveat to readme.md's vue demo is that if a module is reused more than once on the same page, vueInstance can be shared more than once. react won't have this problem because the reatc update is based on container, which is unique.
hack:
The text was updated successfully, but these errors were encountered: