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: 动态删除children子组件 #86

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/uni-mp-vue/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,23 @@ function unmountComponent(instance: ComponentInternalInstance) {
if (bum) {
invokeArrayFns(bum)
}
if (__FEATURE_OPTIONS_API__) {
// $children
const parentInstance = instance.parent
if (parentInstance) {
const $children = parentInstance.ctx.$children as (
| ComponentPublicInstance
| Record<string, any>
)[]

const target = getExposeProxy(instance) || instance.proxy
const index = $children.indexOf(target!)
if (index > -1) {
$children.splice(index, 1)
}
}
}

// stop effects in component scope
scope.stop()
// update may be null if a component is unmounted before its async
Expand Down