Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 【发行为混合分包】TypeError: t.$callHook is not a function #4829

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

viccici
Copy link

@viccici viccici commented Apr 11, 2024

#4781

  1. 当发行为混合分包的时候,uniapp 会调用 initCreateSubpackageApp 方法

  2. initCreateSubpackageApp 里调用 parseApp ,并在 onLaunch 时候进行 initBaseInstance

  3. initCreateSubpackageApp 里调用 parseApp 后同步执行 vm.$.ctx.$scope = app;

  4. initBaseInstance 在 onLaunch 会进行 if (this.$vm && ctx.$scope) {return;} 阻断,如果通过则执行 ctx.$hasHook = hasHook; ctx.$callHook = callHook;

问题出在 onLaunch 是异步的,导致 4 的流程阻断,没有执行 $callHook 赋值,最终导致 initAppLifecycle 中的 vm.$callHook 为 undefined

1. 当发行为混合分包的时候,uniapp 会调用 initCreateSubpackageApp 方法

2. initCreateSubpackageApp 里调用 parseApp ,并在 onLaunch 时候进行 initBaseInstance

3. initCreateSubpackageApp 里调用 parseApp 后同步执行 `vm.$.ctx.$scope = app;`

4. initBaseInstance 在 onLaunch 会进行 `if (this.$vm && ctx.$scope) {return;}` 阻断,如果通过则执行 `ctx.$hasHook = hasHook;  ctx.$callHook = callHook;` 

问题出在 onLaunch 是异步的,导致 4 的流程阻断,没有执行 $callHook 赋值,最终导致 `initAppLifecycle` 中的 `vm.$callHook` 为 undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant