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,
		});
	}
}
相关推荐
当时只道寻常38 分钟前
Vue3 + IntersectionObserver 实现高性能图片懒加载
前端
sakiko_1 小时前
UIKit学习笔记3-布局、滚动视图、隐藏或显示视图
前端·笔记·学习·objective-c·swift·uikit
有一个好名字2 小时前
Agent Loop —— 一切从那个 while 循环开始
前端·javascript·chrome
一天睡25小时2 小时前
Claude Code 指令入门教程
前端
yingyima2 小时前
正则表达式实战:从日志中精准提取关键字段
前端
TeamDev2 小时前
如何在 DotNetBrowser 中使用本地 AI 模型
前端·后端·.net
谢尔登2 小时前
10_从 React Hooks 本质看 useState
前端·ubuntu·react.js
辰同学ovo2 小时前
从全局登录状态管理学习 Redux
前端·javascript·学习·react.js
陈随易3 小时前
2年没用Nodejs了,Bun很香
前端·后端·程序员
donecoding3 小时前
Corepack 完全解析:从懵到懂,包管理器自由了
前端·node.js·前端工程化