微信小程序——解決wx.switchTab: url 不支持 queryString

我對小程序瞭解很少,甚至前端水平還停留在jquery那個層面。話很少說,先看看出了什麼問題?前端

問題描述:

這個小程序是某商城的小程序,發現首頁自定義一些菜單導航過去都是錯誤的。例如原本想要跳轉到「熱門商品」頁去(pages/goods/index/index?ishot=1),但怎麼弄都只能跳轉到pages/goods/index/index(query參數丟失了),併產生一條警告:「wx.switchTab: url 不支持 queryString」。百度了好一會:都是「先存儲到全局js中,再到目標頁onShow時再進行處理」 blog.csdn.net/qq_29644709…jquery

但我記憶中看過其餘小程序是支持帶querystring的導航,因而我分析了源碼,確實沒找到相關的代碼實現,正當失望的時候,忽然發現導航裏有一個pages/goods/index/index, 我猜測 這裏定義了(無querystring,因此其餘地方就不能用了),我嘗試將pages/goods/index/index 修改成 pages/category/index/index後,問題獲得解決。json

#app.json導航部分
"tabBar": {
       "color": "#999999",
       "selectedColor": "#ff5555",
       "borderStyle": "white",
       "backgroundColor": "#f7f7fa",
       "list": [
           {
               "pagePath": "pages/index/index",
               "text": "首頁",
               "iconPath": "static/images/tabbar/icon-1.png",
               "selectedIconPath": "static/images/tabbar/icon-1-active.png"
           },
           {
               "pagePath": "pages/category/index/index",
               "text": "所有分類",
               "iconPath": "static/images/tabbar/icon-2.png",
               "selectedIconPath": "static/images/tabbar/icon-2-active.png"
           },
           {
               "pagePath": "pages/member/cart/index",
               "text": "購物車",
               "iconPath": "static/images/tabbar/icon-4.png",
               "selectedIconPath": "static/images/tabbar/icon-4-active.png"
           },
           {
               "pagePath": "pages/member/index/index",
               "text": "會員中心",
               "iconPath": "static/images/tabbar/icon-5.png",
               "selectedIconPath": "static/images/tabbar/icon-5-active.png"
           }
       ]
   }
複製代碼
相關文章
相關標籤/搜索