设置view到底部的高度

2020-09-07  本文已影响0人  杨义林

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'}">

上一篇 下一篇

猜你喜欢

热点阅读