From dc2018ee179f8a51e6eca328687b63c5209cbb10 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 5 Jun 2026 11:36:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(harmony):=20=E6=95=B0=E6=8D=AE=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=90=8E=E9=80=9A=E8=BF=87=E6=94=B9=E5=8F=98=20slot?= =?UTF-8?q?=20key=20=E5=BC=BA=E5=88=B6=E9=87=8D=E5=BB=BA=E5=88=97=E8=A1=A8?= =?UTF-8?q?=20DOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 根因:鸿蒙 ArkUI 对 slot 内 Vue 响应式更新完全失效 - 之前方案(:class/:style/v-if/)都只能影响 slot 内部,ArkUI 不响应 - 新方案:slot 外包一层 view 绑定动态 key,数据加载后 300ms 自增 key - key 变化强制 Vue 重建整个 slot 子树,完全绕过 ArkUI 响应式限制 - 还原之前无效的 mounted 延迟方案 --- components/mescroll/my-list-mescroll.vue | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/components/mescroll/my-list-mescroll.vue b/components/mescroll/my-list-mescroll.vue index c1f71be..7f241a4 100644 --- a/components/mescroll/my-list-mescroll.vue +++ b/components/mescroll/my-list-mescroll.vue @@ -15,7 +15,9 @@ @init="mescrollInit" > - + + + @@ -45,6 +47,7 @@ export default { onScroll: true }, scrollY: 0, + renderSlotKey: 0, isInit: false }; }, @@ -72,17 +75,8 @@ export default { this.isInit = true; }, mounted() { - // #ifdef MP-HARMONY - // 鸿蒙 ArkUI DOM 初始化较慢,延迟加载确保渲染管线就绪 - setTimeout(() => { - this.mescroll.resetUpScroll(); - this.listenRefresh(); - }, 400); - // #endif - // #ifndef MP-HARMONY this.mescroll.resetUpScroll(); this.listenRefresh(); - // #endif }, methods: { // mescroll组件初始化的回调,可获取到mescroll对象 @@ -101,6 +95,12 @@ export default { upCallback() { //联网加载数据 this.$emit('getData', this.mescroll); + // #ifdef MP-HARMONY + // 鸿蒙 ArkUI 对 slot 内容响应式更新不敏感,数据加载后通过改变 key 强制重建 + setTimeout(() => { + this.renderSlotKey++; + }, 300); + // #endif }, //点击空布局按钮的回调 emptyClick() {