sass使用变量实现动态高度

//topNavigationBar公共header组件

<topNavigationBar :defaultBack="true" titleColor="#393C42" title="购买课程"/>
                //占位view
        <view :style="{'height':navigateBarHeight + 'rpx'}">占位</view>
                //内容content 
        <view class="Content" :style="{'--height':height}">
</view>

//放到 template 里的view

data() {
    return {
        navigateBarHeight:'',
        height:'',
    }
}
created(){
        //header组件返回的高度
    this.navigateBarHeight = pageContantTop()
    this.height = this.navigateBarHeight+'rpx'
},

//content 高度样式

Content{
    height:calc(100% - var(--height) );
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容