caroundsky / QA

0 stars 0 forks source link

微前端micro-zoe #17

Open caroundsky opened 1 year ago

caroundsky commented 1 year ago

基座 Angular 5.x 子应用 vue3 + vite2,UMD模式

系统环境:

因为 Angular 5.x 的TS版本与micro的TS版本不兼容,在ng以ESM的模式引入micro,编译会报语法错误:

企业微信截图_16902774452754

ng5.x的Ts版本即使在 tsconfig.json内配置 skipLibCheck 也无效,故采用umd的方式引入。

// main.js const MicroApp = new window.microApp.MicroApp()

MicroApp.start()


* 在路由页面分别配置view model

```js
// xxx.html
<div id="invoice"></div>

// xxx.ts
ngAfterViewInit() {
  const { renderApp } = window.microApp

  renderApp({
    name: 'invoice',
    container: '#invoice',
    url,
    iframe: true, // 使用vite需要开启该设置
    'default-page': '/#/默认打开路由',
    'keep-alive': true // ng路由切换时,可以保留子应用状态
  })
}

Tips:

1、micro 文档: https://micro-zoe.com/docs/1.x/#/