页面栈

实践:

1)

保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。

wx.switchTab(Object object) | 微信开放文档 https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.switchTab.html

路由格式

// app.json
{
  "tabBar": {
    "list": [{
      "pagePath": "index",
      "text": "首页"
    },{
      "pagePath": "other",
      "text": "其他"
    }]
  }
}
wx.switchTab({
  url: '/index'
})

wx.navigateTo(Object object) | 微信开放文档 https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html

wx.navigateTo(Object object)

以 Promise 风格 调用:支持

需要页面权限:小程序不能在插件页面中调用该接口,插件也不能在小程序页面中调用该接口

小程序插件:支持,需要小程序基础库版本不低于 2.2.2

在小程序插件中使用时,只能在当前插件的页面中调用

微信 Windows 版:支持

微信 Mac 版:支持

保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 wx.navigateBack 可以返回到原页面。小程序中页面栈最多十层

// app.json
{
  "tabBar": {
    "list": [{
      "pagePath": "index",
      "text": "首页"
    },{
      "pagePath": "other",
      "text": "其他"
    }]
  }
}
wx.switchTab({
  url: '/index'
})
原文地址:https://www.cnblogs.com/rsapaper/p/15743416.html