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,
		});
	}
}
相关推荐
英俊潇洒美少年1 天前
Vue 生产环境打包:SourceMap、压缩、混淆、加密全解 + 最佳实践
前端·javascript·vue.js
巴博尔1 天前
UNIAPP中NVUE页面 动画
android·前端·javascript·ios·uni-app
她说人狗殊途1 天前
基于 vue-cli 创建
前端·javascript·vue.js
AZaLEan__1 天前
前端移动端适配与 Bootstrap
前端·bootstrap·html
大家的林语冰1 天前
Deno 2.8 正式发布,再次超越 Bun,史上最大的次版本升级诞生!
前端·javascript·node.js
渣渣xiong1 天前
从零开始:前端转型AI agent直到就业第五十七天-第五十八天
前端·人工智能·python
AI周红伟1 天前
周红伟:长鑫科技(CXMT)财务全景分析
前端·chrome·科技
excel1 天前
JS 正则在多次 test() 时为什么会出现 lastIndex 缓存问题?
前端
IT_陈寒1 天前
为什么 Java 的 Optional 让我调试到深夜?
前端·人工智能·后端
米丘1 天前
React 19.x 的 lazy 与 Suspense
前端·javascript·react.js