main.js
let instance = null;
export async function mount(props) {
// 接收主应用传来的
window.commonComponents = props.commonComponents
window.loadMicroApp = props.loadMicroApp;
Vue.prototype.$win = props.window
Vue.prototype.$store = Vue.observable(props.store)
Vue.prototype.$request = props.request
Vue.prototype.parentRouter = props.router
Vue.prototype.$checkPermi = props.checkPermi
Vue.prototype.checkRole = props.checkRole
Vue.use(props.directive)
render(props)
}
// 子应用渲染
function render(params) {
instance = new Vue({
router,
store:Vue.observable(params.store),
data(){
return{
...params
}
},
render: h => h(App),
}).$mount('#subFoundation');
}
export async function bootstrap() {
console.log('react app bootstraped');
}
if (!window.__POWERED_BY_QIANKUN__) {
console.log('独立运行')
new Vue({
el: '#subActivity',
router,
store: microStore,
render: (h) => h(App),
});
}
export const eventBus = new Vue()
export async function unmount() {
instance.$destroy();
instance = null;
}