乾坤生命周期及window指向

乾坤集成生命周期管理:从bootstrap到unmount,
本文详细描述了乾坤集成的生命周期过程,包括bootstrap、fetch、active、mounted和unmount阶段,以及每个阶段window对象的指向变化。强调了子应用在不同阶段对主应用全局资源的访问规则和官方文档的参考价值。

乾坤集成的生命周期包括以下几个主要阶段:

  1. bootstrap 阶段:主应用加载阶段,负责初始化乾坤实例和加载子应用的静态资源。

  2. fetch 阶段:主应用发送一个 HTTP 请求,获取子应用的入口资源(一般是一个 js 文件)。

  3. active 阶段:主应用获取到子应用的入口资源后,在一个沙盒环境中运行子应用的初始化函数,并将子应用的代码注入到页面中。

  4. mounted 阶段:子应用初始化成功后,会触发 mount 生命周期钩子函数,此时子应用已经完全加载并准备就绪。

  5. unmount 阶段:当主应用决定卸载子应用时,会触发 unmount 生命周期钩子函数,用于清理子应用的资源。

在上述生命周期中,window 对象会根据具体的阶段指向不同的对象:

  • bootstrap 阶段:window 对象指向主应用的全局对象。

  • fetch 阶段:window 对象指向主应用的全局对象。

  • active 阶段:window 对象指向主应用的全局对象。

  • mounted 阶段:window 对象指向当前子应用的全局对象。

  • unmount 阶段:window 对象指向当前子应用的全局对象。

需要注意的是,在不同的生命周期阶段,window 对象的指向可能会发生变化,并且子应用的代码中只能访问到当前生命周期阶段对应的 window 对象。如果子应用需要访问主应用的全局变量和方法,在不同阶段需要适时进行判断或等待。具体的使用方式和注意事项建议参考乾坤集成的官方文档。

error occurs while executing entry script http://localhost:3002/src/main.jsx exec @ index.js:286 schedule @ index.js:321 schedule @ index.js:326 schedule @ index.js:326 schedule @ index.js:326 (匿名) @ index.js:331 (匿名) @ index.js:330 Promise.then _execScripts @ index.js:261 execScripts @ index.js:391 _callee17$ @ loader.js:327 (匿名) @ regeneratorRuntime.js:52 (匿名) @ regenerator.js:52 (匿名) @ regeneratorDefine.js:17 asyncGeneratorStep @ asyncToGenerator.js:3 _next @ asyncToGenerator.js:17 Promise.then asyncGeneratorStep @ asyncToGenerator.js:8 _next @ asyncToGenerator.js:17 Promise.then asyncGeneratorStep @ asyncToGenerator.js:8 _next @ asyncToGenerator.js:17 Promise.then asyncGeneratorStep @ asyncToGenerator.js:8 _next @ asyncToGenerator.js:17 Promise.then asyncGeneratorStep @ asyncToGenerator.js:8 _next @ asyncToGenerator.js:17 (匿名) @ asyncToGenerator.js:22 (匿名) @ asyncToGenerator.js:14 _loadApp @ loader.js:614 loadApp @ loader.js:188 _callee3$ @ apis.js:79 (匿名) @ regeneratorRuntime.js:52 (匿名) @ regenerator.js:52 (匿名) @ regeneratorDefine.js:17 asyncGeneratorStep @ asyncToGenerator.js:3 _next @ asyncToGenerator.js:17 Promise.then asyncGeneratorStep @ asyncToGenerator.js:8 _next @ asyncToGenerator.js:17 (匿名) @ asyncToGenerator.js:22 (匿名) @ asyncToGenerator.js:14 app2 @ apis.js:118 (匿名) @ load.js:39 Promise.then (匿名) @ load.js:38 Promise.then X @ load.js:24 (匿名) @ reroute.js:78 Promise.then d2 @ reroute.js:77 Rt @ reroute.js:69 bt @ apps.js:133 (匿名) @ apis.js:66 registerMicroApps @ apis.js:59 (匿名) @ main.ts:45 main.ts:45 [import-html-entry]: error occurs while executing normal script <script type="module">import { injectIntoGlobalHook } from "/@react-refresh"; injectIntoGlobalHook(window); window.$RefreshReg$ = () => {}; window.$RefreshSig$ = () => (type) => type;</script>
08-21
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值