fix(harmony): 数据加载后调用 scrollTo 强制 mescroll 重新计算内容高度

- 根因:mescroll 初始化时 setClientHeight 在 slot 内容渲染前执行,测得高度为 0
- 数据加载后 mescroll 不知道内容高度已变化,scroll-view 仍保持 0 高度
- 点击排序后触发 refresh() → setClientHeight() 重新测量,内容才显示
- 修复:数据加载后调用 scrollTo(0, 0) 强制 mescroll 重新测量内容高度
- mescroll-uni.vue 同步暴露 scrollTo 方法供外部调用
This commit is contained in:
2026-06-05 11:47:22 +08:00
parent a23d57547b
commit 2ec9aa990f
2 changed files with 15 additions and 0 deletions

View File

@@ -217,6 +217,9 @@
}
},
methods: {
scrollTo(y, t) {
this.mescroll.scrollTo(y, t);
},
//number,rpx,upx,px,% --> px的数值
toPx(num) {
if (typeof num === 'string') {

View File

@@ -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 => {