fix(merch/detail): 修复头部高度重复初始化的问题

添加headerHeightInited标记,避免merch数据更新时重复调用初始化方法
This commit is contained in:
2026-05-29 14:35:52 +08:00
parent a443121426
commit 1edda80d21

View File

@@ -321,16 +321,19 @@ export default {
data() {
return {
headerHeight: 320,
screenWidth: uni.getSystemInfoSync().windowWidth
screenWidth: uni.getSystemInfoSync().windowWidth,
headerHeightInited: false
};
},
mixins: [list],
watch: {
merch: {
handler() {
this.$nextTick(() => {
this.initHeaderHeight();
});
if (!this.headerHeightInited) {
this.$nextTick(() => {
this.initHeaderHeight();
});
}
},
deep: true
}
@@ -349,8 +352,9 @@ export default {
setTimeout(() => {
const query = uni.createSelectorQuery().in(this);
query.select('.head-wrap').boundingClientRect(rect => {
if (rect) {
if (rect && rect.height > 0) {
this.headerHeight = (rect.height / this.screenWidth) * 750;
this.headerHeightInited = true;
}
}).exec();
}, 100);