uniapp自定义导航栏navbar
<u-navbar title="首页" :bgColor="bgColor" :titleStyle='titleStyle'> <view class="u-nav-slot" slot="left"> //左边插槽 </view> <view class="u-nav-slot" slot="center"> --> <text>首页</text> </view> <view class="u-nav-slot" slot="right"> //右边插槽 </view> </u-navbar>
<view class="content" :style="{ marginTop: height + 'px' }"> <!-- 正文内容 --> </view>
自定义完导航栏需要动态判断当前导航栏高度
getSystemInfo(){ let stateHeight = '';//任务栏高度 //胶囊距离顶部距离//胶囊高度 const { top , height } = wx.getMenuButtonBoundingClientRect() wx.getSystemInfoAsync({ success: (result) => { stateHeight = result.statusBarHeight;//状态栏高度 let sum = '' sum = stateHeight + height + (top - stateHeight)*2 this.setData({ height:sum + 'px' }) }, })
本文来自博客园,作者:小万子呀,转载请注明原文链接:https://www.cnblogs.com/newBugs/p/15905364.html