您好,欢迎访问一九零五行业门户网

uni-app如何跳转页面

跳转方法:1、使用“uni.navigateto(object)”;2、使用“uni.redirectto(object)”;3、使用“uni.relaunch(object)”;4、使用“uni.switchtab(object)”等。
本教程操作环境:windows7系统、uni-app2.5.1版,dell g3电脑。
uni-app 页面跳转主要有下面5个方法完成。分别如下:
(1)uni.navigateto(object) 保留当前页面,跳转到应用内的某个页面
(2)uni.redirectto(object) 关闭当前页面,跳转到应用内的某个页面
(3)uni.relaunch(object) 关闭所有页面,打开到应用内的某个页面
(4)uni.switchtab(object) 跳转到 tabbar 页面,并关闭其他所有非 tabbar 页面
(5)uni.navigateback(object) 关闭当前页面,返回上一页面或多级页面
uni.navigateto(object)
保留当前页面,跳转到应用内的某个页面,使用uni.navigateback可以返回到原页面。object参数说明:参数类型必填说明urlstring是需要跳转的应用内非 tabbar 的页面的路径 , 路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;
uni.navigateto({url: 'test?id=1&name=uniapp'});export default {onload: function (option) {console.log(option.id);console.log(option.name); }}
uni.redirectto(object)
关闭当前页面,跳转到应用内的某个页面。object参数说明参数类型必填说明urlstring是需要跳转的应用内非 tabbar 的页面的路径,路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;
uni.redirectto({url: 'test?id=1' // 传递参数 id,值为1});
uni.relaunch(object)
关闭所有页面,打开到应用内的某个页面。object参数说明:参数类型必填说明urlstring是需要跳转的应用内页面路径 , 路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;
uni.relaunch({url: 'test?id=1'});export default {onload: function (option) {console.log(option.query);   }}
uni.switchtab(object)
跳转到 tabbar 页面,并关闭其他所有非 tabbar 页面。object参数说明:参数类型必填说明urlstring是需要跳转的 tabbar 页面的路径(需在 app.json 的 tabbar 字段定义的页面),路径后不能带参数
pages.json{tabbar: {list: [{pagepath: index,text: 首页},{pagepath: other,text: 其他      }]   }}other.vueuni.switchtab({url: 'index'});
uni.navigateback(object)
关闭当前页面,返回上一页面或多级页面。可通过 getcurrentpages() 获取当前的页面栈,决定需要返回几层。object参数说明:参数类型必填说明deltanumber1返回的页面数,如果 delta 大于现有页面数,则返回到首页。
uni.navigateto({url: 'b?id=1'});uni.navigateto({url: 'c?id=1'});uni.navigateback({delta: 2});
【相关推荐:《uniapp教程》】
以上就是uni-app如何跳转页面的详细内容。
其它类似信息

推荐信息