uniapp小程序原生导航栏返回按钮-自定义返回路径

onBackPress(e) {
    if (e.from == "backbutton") {
      uni.switchTab({
        url: "返回页为tab页面路径",
      });
      uni.navigateTo({
        url: "返回页非tab页面路径",
      });
      return true; //阻止默认返回行为
    }
 }

原代码,运行到微信开发者工具无作用

查看官网发现该方法不支持微信小程序

onUnload() {
    //#ifdef MP-WEIXIN
    wx.reLaunch({
      url: '跳转路径'
    })
    //#endif
  },

可以改用页面生命周期onUnload方法监听页面卸载实现该功能

猜你喜欢

转载自blog.csdn.net/KillmuMo/article/details/131954301