1.得到view到上部的距离
const query = wx.createSelectorQuery()
query.select('#src_box').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec((res) =>{
console.log(res);
this.boxToTop = res[0].top
})
2.得到屏幕的高度
uni.getSystemInfo({
success: res => {
this.windowH = res.windowHeight
}
})
3.添加计算属性,得到的值传给子组件
computed: {
getHeight() {
this.boxHeight = this.windowH - this.boxToTop
}
}
4.子组件接收后,给view添加样式
<view class="content" :style="{height: boxHeight + 'px'}">
网友评论