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'
        })
      },
    })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM