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:
@@ -217,6 +217,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
scrollTo(y, t) {
|
||||||
|
this.mescroll.scrollTo(y, t);
|
||||||
|
},
|
||||||
//number,rpx,upx,px,% --> px的数值
|
//number,rpx,upx,px,% --> px的数值
|
||||||
toPx(num) {
|
toPx(num) {
|
||||||
if (typeof num === 'string') {
|
if (typeof num === 'string') {
|
||||||
|
|||||||
@@ -259,6 +259,18 @@ export default {
|
|||||||
this.goodsList = this.goodsList.concat(newArr); //追加新数据
|
this.goodsList = this.goodsList.concat(newArr); //追加新数据
|
||||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
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);
|
this.waterfallflow((mescroll.num - 1) * 10);
|
||||||
},
|
},
|
||||||
fail: res => {
|
fail: res => {
|
||||||
|
|||||||
Reference in New Issue
Block a user