fix(harmony): 双列模式,点击图片等不能进入商品详情页面

This commit is contained in:
2026-06-05 17:39:50 +08:00
parent dcc261b0d0
commit 4f44b4f574
3 changed files with 19 additions and 19 deletions

View File

@@ -298,6 +298,14 @@ export default {
},
changeListStyle() {
this.isList = !this.isList;
// 鸿蒙下 isList 切换导致 :key 变化、DOM 重建,重建出来的 .goods-item @click 事件绑定会丢失
// 主动触发 slot 重建,把事件绑定带回来
// #ifdef MP-HARMONY
const mescroll = this.$refs.mescroll;
if (mescroll && typeof mescroll.forceSlotRebuild === 'function') {
mescroll.forceSlotRebuild();
}
// #endif
this.waterfallflow(0);
},
//筛选点击
@@ -489,20 +497,6 @@ export default {
},
genNonDuplicate(len = 6) {
return Number(Math.random().toString().substr(3, len) + Date.now()).toString(36);
},
/**
* 鸿蒙下双列 items 一直在 display:none 状态下渲染,首次切换时尺寸测量不对导致瀑布流错位
* 通过 :key 加 isList 前缀,切换模式时强制重建 DOM,新 DOM 在可见状态下生成,测量正确
* H5/微信不受影响,走原 item.id
*/
goodsItemKey(item) {
// #ifdef MP-HARMONY
return (this.isList ? 's-' : 'd-') + item.id;
// #endif
// #ifndef MP-HARMONY
return item.id;
// #endif
}
}
}