uniapp 路由跳转方式

javascript 复制代码
export function goBack(index, url) {
	if (index == 1) { 
		// 关闭当前页,返回上一页面或多级页面。
		uni.navigateBack({
			delta: url,
			animationType: 'pop-out',
			animationDuration: 300
		});
	} else if (index == 2) { 
		// 保留当前页,跳转到非tabbar页面,使用uni.navigateBack可以返回到原页面。
		uni.navigateTo({
			url: url,
			animationType: 'pop-in',
			animationDuration: 300
		})
	} else if (index == 3) {
		// 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面。
		uni.switchTab({
			url: url,
			animationType: 'pop-in',
			animationDuration: 300
		})
	} else if (index == 4) {
		// 关闭所有页面,打开到应用内的某个页面。
		uni.reLaunch({
			url: url,
			animationType: 'pop-in',
			animationDuration: 300
		})
	} else if (index == 5) {
		// 关闭当前页面,跳转到应用内的某个页面。
		uni.redirectTo({
			url: url,
		});
	}
}
相关推荐
Moment3 分钟前
AI 全栈指南:NestJs 中的 Service Provider 和 Module
前端·后端·面试
IT_陈寒6 分钟前
为什么我的JavaScript异步回调总是乱序执行?
前端·人工智能·后端
Moment9 分钟前
AI全栈入门指南:NestJs 中的 DTO 和数据校验
前端·后端·面试
小码哥_常20 分钟前
告别RecyclerView卡顿!8个优化技巧让列表丝滑如德芙
前端
小村儿30 分钟前
Harness Engineering:为什么你用 AI 越用越累?
前端·后端·ai编程
enoughisenough1 小时前
浏览器判断控制台是否开启
前端
Moment1 小时前
当前端开始做 Agent 后,我才知道 LangGraph 有多重要❗❗❗
前端·后端·面试
竹林8181 小时前
RainbowKit 快速集成多链钱包连接:从“连不上”到丝滑切换的踩坑实录
前端·javascript
小蜜蜂dry1 小时前
nestjs实战-登录、鉴权(一)
前端·后端·nestjs
农夫山泉不太甜1 小时前
WebSocket与SSE技术方案选型对比分析
前端