From 2ec9aa990f5be9117896cff83e1986f3bdaa2d6e Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 5 Jun 2026 11:47:22 +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=E8=B0=83=E7=94=A8=20scrollTo=20=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=20mescroll=20=E9=87=8D=E6=96=B0=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 根因:mescroll 初始化时 setClientHeight 在 slot 内容渲染前执行,测得高度为 0 - 数据加载后 mescroll 不知道内容高度已变化,scroll-view 仍保持 0 高度 - 点击排序后触发 refresh() → setClientHeight() 重新测量,内容才显示 - 修复:数据加载后调用 scrollTo(0, 0) 强制 mescroll 重新测量内容高度 - mescroll-uni.vue 同步暴露 scrollTo 方法供外部调用 --- components/mescroll/mescroll-uni.vue | 3 +++ pages_goods/public/js/list.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/components/mescroll/mescroll-uni.vue b/components/mescroll/mescroll-uni.vue index 3f896ce..7c15c48 100644 --- a/components/mescroll/mescroll-uni.vue +++ b/components/mescroll/mescroll-uni.vue @@ -217,6 +217,9 @@ } }, methods: { + scrollTo(y, t) { + this.mescroll.scrollTo(y, t); + }, //number,rpx,upx,px,% --> px的数值 toPx(num) { if (typeof num === 'string') { diff --git a/pages_goods/public/js/list.js b/pages_goods/public/js/list.js index 25925fb..29ac207 100644 --- a/pages_goods/public/js/list.js +++ b/pages_goods/public/js/list.js @@ -259,6 +259,18 @@ export default { this.goodsList = this.goodsList.concat(newArr); //追加新数据 if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); + // #ifdef MP-HARMONY + // 鸿蒙下 mescroll 初始化时 setClientHeight 在 slot 内容渲染前执行,测得高度为 0 + // 数据加载后 scrollTo(0,0) 强制 mescroll 重新测量内容高度并重置滚动位置 + setTimeout(() => { + if (this.$refs.mescroll && this.$refs.mescroll.scrollTo) { + this.$refs.mescroll.scrollTo(0, 0); + } else if (this.$refs.mescroll && this.$refs.mescroll.mescroll) { + this.$refs.mescroll.mescroll.scrollTo(0, 0); + } + }, 100); + // #endif + this.waterfallflow((mescroll.num - 1) * 10); }, fail: res => {