Wx.switchTab failure

< H1 > wx.switchTab failure < / H1 > < hr >

I get the cookie field in onLaunch of app.js wx.getStorage , and jump to the home page directly via wx.switchTab if it exists. However, if it fails, it will not jump, but the success callback of switchTab will be executed.

app.js onLaunch

onLaunch: function() {
    let that = this;
    // 
    wx.getStorage({
      key: "cookie",
      success: function(res) {
        that.globalData.cookie = res.data
        wx.switchTab({
          url: "/pages/home/index",
          success:res=>{
            console.log(res);
          },
          fail:err=>{
            console.log(err)
          }
        })
      }), 

app.json

{
  "pages": [
    "pages/login/login",
    "pages/home/index",
    "pages/me/index",
    "pages/news/index",
    "pages/home/pages/leave/index",
    "pages/home/pages/count/index",
    "pages/home/pages/count/pages/next/next",
    "pages/home/pages/profile/index"
  ],
  "window": {
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "-sharpfff",
    "navigationBarTitleText": "WeChat",
    "navigationBarTextStyle": "black"
  },
  "tabBar": {
    "color": "-sharpa9b7b7",
    "selectedColor": "-sharp11cd6e",
    "borderStyle": "white",
    "list": [
      {
        "selectedIconPath": "images/index/index.png",
        "iconPath": "images/index/index.png",
        "pagePath": "pages/home/index",
        "text": ""
      },
      {
        "selectedIconPath": "images/index/message.png",
        "iconPath": "images/index/message.png",
        "pagePath": "pages/news/index",
        "text": ""
      },
      {
        "selectedIconPath": "images/index/user.png",
        "iconPath": "images/index/user.png",
        "pagePath": "pages/me/index",
        "text": ""
      }
    ]
  }
}
Oct.19,2021

switchTab the url of the jump is the relative address relative to the current page. I understand that the onLaunch and onShow of .. / home/index


app.js register the page only after execution, so you cannot jump at this time, you can put it on the startup page, or setTimeout

in app.js.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a864-2c24b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a864-2c24b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?