- 如何加载子模块?
- 开发模式 ipPath = 'http://localhost:9001'
- 生产模式 ipPath = 'xx.xx.xx:9001'
let timestamp = new Date().getTime(); ipPath/modules/{ele.code}/app.js?v=${timestamp}`
window.System.import(compUrl)// 模块加载器导入js模块,需要相对路径或者绝对路径
-
子模块打包后的html 有什么用? 独立启动时网页入口
-
路由是什么时候添加的? 子模块mount声明周期时,将后端查询资源管理菜单中配置的路由返回到前端,然后router.addRoute添加到路由中。 可以优化为:动态路由加载
-
子模块之间如何通信 维护同一份vuex,通过script标签引入vuex
window.Vue = Vue
window.Vuex = Vuex
window.Vue.use(window.Router)
window.Vue.use(window.Vuex)
基座和子模块的通信
singleSpa.mountRootParcel(appModel, {
appName: app.name,
domElement: document.getElementById(app.name),
keepAliveTabs: store.state.keepAliveTabs[app.name],
store: store.state.outputStore,
dynamicRoutes: currentAppRoutes
});