真机运行在Ios版本14及以下使用跳转uni.relaunch时uni-app路由跳转失效

真机运行在Ios版本14及以下使用跳转uni.relaunch时uni-app路由跳转失效

示例代码:

// tabBar页面:/pages/question/index
uni.reLaunch({
url: "/pages/question/index",
});

操作步骤:

使用ios手机版本低于15的进行真机调试,使用路由跳转方法,uni.reLaunch、uni.switchTab、uni.navigateTo,查看HBuilderX控制台进行复现

预期结果:

希望官方修复一下这个问题,期望可以正常跳转

实际结果:

路由跳转失败,报错{"errMsg":"reLaunch:fail null is not an object (evaluating 're.el=al.el')"} __ERROR

bug描述:

uniapp打包成app,已经测试了版本号高于15的可以正常跳转,ios版本为15以下的用户,路由跳转失效;

于是使用版本为12.5.7的ios手机进行真机调试,发现路由跳转失效,使用的是uni.reLaunch({url:‘url’}),HBuilderX报错信息为{"errMsg":"reLaunch:fail null is not an object (evaluating 're.el=al.el')"} __ERROR,试过换成uni.switchTab、uni.navigateTo都是报not an object

信息类别 信息内容
产品分类 uniapp/App
PC开发环境 Windows
PC系统版本号 Windows 10 专业版 22H2
HBuilderX类型 正式
HBuilderX版本 4.76
手机系统 iOS
手机系统版本号 iOS 12.4
手机厂商 苹果
手机机型 iPhone 5s
页面类型 vue
vue版本 vue3
打包方式 云端
项目创建方式 HBuilderX

示例图片


更多关于真机运行在Ios版本14及以下使用跳转uni.relaunch时uni-app路由跳转失效的实战教程也可以访问 https://www.itying.com/category-93-b0.html

11 回复

hello , 能够文档复现吗?使用自定义基座还是云打包呢?

更多关于真机运行在Ios版本14及以下使用跳转uni.relaunch时uni-app路由跳转失效的实战教程也可以访问 https://www.itying.com/category-93-b0.html


你好,ios系统低于15版本,用标准基座运行、自定义基座、云打包都会有这个报错,直接使用uni.reLaunch、uni.switchTab、uni.navigateTo就能复现出来了,下面这些是我项目用到的依赖,帮忙看看是不是没有兼容低版本ios呢?

“dependencies”: { “@dcloudio/uni-app”: “3.0.0-4040520250104002”, “@dcloudio/uni-app-harmony”: “3.0.0-4040520250104002”, “@dcloudio/uni-app-plus”: “3.0.0-4040520250104002”, “@dcloudio/uni-components”: “3.0.0-4040520250104002”, “@dcloudio/uni-h5”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-alipay”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-baidu”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-jd”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-kuaishou”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-lark”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-qq”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-toutiao”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-weixin”: “3.0.0-4040520250104002”, “@dcloudio/uni-mp-xhs”: “3.0.0-4040520250104002”, “@dcloudio/uni-quickapp-webview”: “3.0.0-4040520250104002”, “crypto-js”: “^4.2.0”, “dayjs”: “^1.11.13”, “text-encoding-shim”: “^1.0.5”, “vue”: “^3.4.21”, “vue-i18n”: “^9.1.9”, “vuex”: “^4.1.0” }, “devDependencies”: { “@dcloudio/types”: “^3.4.8”, “@dcloudio/uni-automator”: “3.0.0-4040520250104002”, “@dcloudio/uni-cli-shared”: “3.0.0-4040520250104002”, “@dcloudio/uni-stacktracey”: “3.0.0-4040520250104002”, “@dcloudio/uni-uts-v1”: “^3.0.0-4040520250104002”, “@dcloudio/vite-plugin-uni”: “3.0.0-4040520250104002”, “@vue/runtime-core”: “^3.4.21”, “gulp”: “^4.0.2”, “gulp-watch”: “^5.0.1”, “minimist”: “^1.2.5”, “sass”: “^1.85.1”, “sass-loader”: “^10.5.2”, “vite”: “5.2.8” }

回复 1***@qq.com: 更新一下依赖版本,重新打一下基座看看呢

回复 DCloud_UNI_yuhe: 但是不使用自定义基座,使用标准基座运行,也是这种情况

回复 1***@qq.com: 可以提供一个测试项目吗?

回复 DCloud_UNI_yuhe: HBuilderX版本是最新的,我这边不确定哪个依赖版本有问题,能帮忙排查一下哪个依赖版本有问题吗

回复 1***@qq.com: 你得提供一下复现工程才能排查的

回复 DCloud_UNI_yuhe: 你好,帮忙看看,我这边重新梳理了报错,我这边uni.reLaunch是跳转了tabbar页面,tabbar页面路由失效前有一个这个报错:Cp@weex-main-jsfm.js:26:233050 ERROR,后面才报错{“errMsg”:“reLaunch:fail null is not an object (evaluating ‘re.el=al.el’)”} ERROR,截图我补充到评论区上,目前还没定位到报错问题;查了跟这个人反馈的情况类似,https://ask.dcloud.net.cn/question/195606

补充截图:这边uni.reLaunch是跳转了tabbar页面,tabbar页面路由失效前有一个这个报错:Cp@weex-main-jsfm.js:26:233050 ERROR,后面才报错{“errMsg”:“reLaunch:fail null is not an object (evaluating ‘re.el=al.el’)”} ERROR

这是一个已知的 iOS 14 及以下版本的兼容性问题,主要出现在 uni-app 路由跳转时。从错误信息 null is not an object (evaluating 're.el=al.el') 来看,这是底层框架在处理路由元素引用时出现的异常。

问题分析: 该问题通常与 iOS 14 及以下版本对 JavaScript 执行环境的差异有关,特别是在处理 Vue 3 组合式 API 和路由生命周期时可能出现引用丢失。由于 uni.reLaunch 会重新初始化页面栈,在低版本 iOS 上可能无法正确完成 DOM 元素绑定。

临时解决方案:

  1. 使用路由跳转替代方案:对于 tabBar 页面跳转,可以优先使用 uni.switchTab 并配合 setTimeout 延迟执行:

    setTimeout(() => {
      uni.switchTab({
        url: '/pages/question/index'
      })
    }, 100)
    
  2. 降级处理:在需要跳转的页面添加条件判断,针对 iOS 14 及以下版本使用原生导航栏控制:

    // 检测 iOS 版本
    const isIOS14OrBelow = /OS (1[0-4]_\d)/.test(navigator.userAgent)
    if (isIOS14OrBelow) {
      window.location.reload()
    } else {
      uni.reLaunch({ url: '/pages/question/index' })
    }
回到顶部