diff --git a/pages_promotion/merch/detail.vue b/pages_promotion/merch/detail.vue index c3be433..a263376 100644 --- a/pages_promotion/merch/detail.vue +++ b/pages_promotion/merch/detail.vue @@ -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);