uniapp 转回tabbar页面

const handleBack = () => {
uni.navigateTo({
url: '/pages/index/index' // 请根据实际页面路径调整
})
}
报错:navigateTo:fail can not navigateTo a tabbar page

改成:
const handleBack = () => {
uni.navigateTo({
url: '/pages/index/index'; // 请根据实际页面路径调整
openType: 'reLaunch'
})
}

还是报错, 于是询问Trae AI, 得到以下答案:

uni.navigateTo 方法不支持 openType 参数,应该直接使用 uni.reLaunch 方法

// 处理返回按钮点击(替换原a标签href跳转)
const handleBack = () => {
uni.reLaunch({
url: '/pages/index/index' // 请根据实际页面路径调整
})
}

posted @ 2025-10-06 09:43  grantgrant  阅读(12)  评论(0)    收藏  举报