天天看點

微信小程式tabBar底部導航 不顯示問題解析

2019年十月八号

{
  "pages": [
    "pages/splash/splash",
    "pages/zhuye/zhuye",
    "pages/list/list",
    "pages/item/item",
    "pages/search/search",
    "pages/profile/profile"
  ],
  "window": {
    "navigationBarBackgroundColor": "#35495e",
    "navigationBarTextStyle": "white",
    "navigationBarTitleText": "電影 « 豆瓣",
    "backgroundColor": "#fff",
    "backgroundTextStyle": "dark",
    "enablePullDownRefresh": true
  },
  "tabBar": {
   
    "list": [
      {
        
        "pagePath":  "pages/zhuye/zhuye",
        "iconPath": "images/board.png",
        "selectedIconPath": "images/board-actived.png",
        "text": "榜單"
      },
      {
       
        "pagePath": "pages/search/search",
        "iconPath": "images/search.png",
        "selectedIconPath": "images/search-actived.png",
         "text": "搜尋"
      },
      {
        
        "pagePath": "pages/profile/profile",
        "iconPath": "images/profile.png",
        "selectedIconPath": "images/profile-actived.png",
        "text": "我的"
      }
    ]
  },

      

解決方案一:把 tabBar配置中的 "pagePath": "pages/zhuye/zhuye", 換成 配置為首頁的pages/splash/splash 就可以了;(簡單說就是有底部導航欄的那個稱為首頁,首頁就應該放到第一個位置上,初始值也是第一個)

<navigator url="../zhuye/zhuye" open-type="switchTab" >
           <button class="btn" bindtap="start" wx:if="{{index == movies.length - 1}}" >立即體驗</button>
      </navigator>
      
//相容詳情傳回首頁底部消失的問題
      wx.switchTab({
          url :  self.indexPagePath,//url路徑
          success(res){

          },
          fail(){ //容錯處理
              wx.navigateBack({
                  delta: 1,
                  fail:function(){
                      wx.reLaunch({
                          url: self.indexPagePath //url路徑
                      })
                  }
              })
          }
      })

      

繼續閱讀