微信小程式連線無法跳轉提示can not navigate to tabBar page錯誤
若是在全域性app.json中配置了tabBar。那麼在開發中呼叫wx.navigateTo介面時候,若是跳轉的url與tabBar中list頁面中引用同樣的
頁面路徑,那麼結果會是無法跳轉。【開發版本:0.12.130400】
上面的是官方的解釋,下面是我的程式碼報錯,這個是app.json; 裡面的配置項,"pagePath": "pages/logs/logs",
{ "pages":[ "pages/index/index", "pages/logs/logs" ], "window":{ "backgroundTextStyle":"light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "WeChat", "navigationBarTextStyle":"black" }, "tabBar": { "list": [{ "pagePath": "pages/index/index", "text": "首頁" }, { "pagePath": "pages/logs/logs", "text": "詳情" }] } }
這個是我介面的index.js
Page({ data:{ // text:"這是一個頁面" }, onLoad:function(options){ // 頁面初始化 options為頁面跳轉所帶來的引數 console.log(options); }, onReady:function(){ // 頁面渲染完成 console.log("---index page onReady---"); }, onShow:function(){ // 頁面顯示 console.log("---index page onShow---"); }, onHide:function(){ // 頁面隱藏 console.log("---index page onHide---"); }, onUnload:function(){ // 頁面關閉 console.log("---index page onUnload---"); }, itemClick : function (){ wx.navigateTo({ url:"../logs/logs?id=1", success: function (res) { console.log(res.data+"1") }, fail: function (err) { console.log(err) } }) console.log(1111); } })
app.js和itemClick函式跳轉介面衝突了,官方的要求是:
如果在這種情況下無法實現跳轉並出現can not navigate to tabBar page錯誤,很有可能是由於在底部tabbar裡面定義樂同樣連線地址的bar,如果在底部footer頁面定義了相同地址的bar,則此頁面無法跳轉,