header的高度,设置为info的80%,动态获取info的高度。
beforeCreate() {
var infoHeight = 0;
const query = uni.createSelectorQuery().in(this);
query.selectAll('.info-items').boundingClientRect();
query.exec((res) => {
// 获取info-items的高度
infoHeight = res[0][0].height;
// console.log(infoHeight);
// 这个加减计算,一定要在query内部
this.headerHeight = infoHeight*0.8+'px';
// console.log(this.headerHeight);
})
},
<view class="header" :style="{height:headerHeight}"></view>