From 41b186f88828433fe897fff79b4ab367d3ce4e10 Mon Sep 17 00:00:00 2001 From: DCloud_UNI_BFC Date: Wed, 11 Sep 2024 15:06:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=8A=A8=E6=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?children=E5=AD=90=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-mp-vue/src/renderer.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/uni-mp-vue/src/renderer.ts b/packages/uni-mp-vue/src/renderer.ts index 98c7b8b5305..ece76df2f93 100644 --- a/packages/uni-mp-vue/src/renderer.ts +++ b/packages/uni-mp-vue/src/renderer.ts @@ -405,6 +405,23 @@ function setupRenderEffect(instance: ComponentInternalInstance) { function unmountComponent(instance: ComponentInternalInstance) { const { bum, scope, update, um } = instance + if (__FEATURE_OPTIONS_API__) { + // $children + const parentInstance = instance.parent + if (parentInstance) { + let $children = parentInstance.ctx.$children as ( + | ComponentPublicInstance + | Record + )[] + + let target = getExposeProxy(instance) || instance.proxy + let index = $children.indexOf(target!) + if (index > -1) { + $children.splice(index, 1) + } + } + } + // beforeUnmount hook if (bum) { invokeArrayFns(bum) From 5150b36e452a6b5b14d64fbfbe36489c4c4f0de3 Mon Sep 17 00:00:00 2001 From: DCloud_UNI_BFC Date: Wed, 11 Sep 2024 15:28:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=8A=A8=E6=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?children=E5=AD=90=E8=8A=82=E7=82=B9=E6=97=B6=E6=9C=BA=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-mp-vue/src/renderer.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/uni-mp-vue/src/renderer.ts b/packages/uni-mp-vue/src/renderer.ts index ece76df2f93..370ea644067 100644 --- a/packages/uni-mp-vue/src/renderer.ts +++ b/packages/uni-mp-vue/src/renderer.ts @@ -405,27 +405,27 @@ function setupRenderEffect(instance: ComponentInternalInstance) { function unmountComponent(instance: ComponentInternalInstance) { const { bum, scope, update, um } = instance + // beforeUnmount hook + if (bum) { + invokeArrayFns(bum) + } if (__FEATURE_OPTIONS_API__) { // $children const parentInstance = instance.parent if (parentInstance) { - let $children = parentInstance.ctx.$children as ( + const $children = parentInstance.ctx.$children as ( | ComponentPublicInstance | Record )[] - let target = getExposeProxy(instance) || instance.proxy - let index = $children.indexOf(target!) + const target = getExposeProxy(instance) || instance.proxy + const index = $children.indexOf(target!) if (index > -1) { $children.splice(index, 1) } } } - // beforeUnmount hook - if (bum) { - invokeArrayFns(bum) - } // stop effects in component scope scope.stop() // update may be null if a component is unmounted before its async