vue-mfe icon indicating copy to clipboard operation
vue-mfe copied to clipboard

Docs: 缺失,遗漏,需要增强的部分

Open givingwu opened this issue 3 years ago • 8 comments

  • 开发的正确流程是什么?
  1. 编写主应用
  2. 发布主应用
  3. 编写子应用
  4. 依赖主应用
  5. 更改子应用 webpack 入口为主应用
  6. 启动子应用实际上启动的是主应用
  7. 主应用加载子应用
  8. 开始开发子应用
  • 每个子运用开发都要基于主运用吗?

Yep.

  • 子运用自己不用启服务?

前端服务肯定是需要启动的。而且依赖主应用为运行时。

  • 每次开发新的子运用就启动主运用?

主应用对于子应用来说就像 nodeJS 应用于 nodeJS 容器的关系。子应用都被放到主应用中动态装载执行。

  • 调试就 resources 本地引入子运用吗?

Yep.

  • 应用之间如何跨应用懒加载组件? 假设有 App, SubApp1, SubApp2,现在 SubApp1 使用 SubApp2 的组件。
  1. 需要 SubApp2 显示暴露组件
import VueMfe from 'vue-mfe'
import routes from './router/routes'

export default VueMfe.createSubApp({
  prefix: 'SubApp2',
  routes,
  components: {
    LazyComponent: () => import('./components/LazyComponent'),
  }
})
  1. 打包 SubApp2 上传到 OSS or CDN 服务器
  2. 通过 VueMfe.lazy('SubApp2.components.LazyComponent') 配合 Vue Async component 方式懒加载组件
import VueMfe from 'vue-mfe'

export default {
  name: 'PageIndex',
  components: {
    LazyComponent: () => VueMfe.Lazy('SubApp2.components.LazyComponent')
  }
}

givingwu avatar Oct 26 '20 01:10 givingwu