uniapp页面跳转+携带参数
·
1、问题:navigateTo:fail can not navigateTo a tabbar page

原因:uni.navigateTo不能跳转到tabbar页面 ,需要跳转tabbar页面路由只能使用uni.switchTab
解决办法:将uni.navigateTo改为uni.switchTab

2、跳转页面重新加载使用uni.reLaunch
使用uni.reLaunch跳转页面会重新渲染,解决数据变化页面不变问题
uni.reLaunch({
url:/pages/index/index
})
3、路由跳转携带参数
在url地址后面拼接=》?params=123
例如 传递参数名id 值为123456
传递多个就在后边加上 &
uni.reLaunch({
url:"/pages/index/index?id=123456&string=字符串"
})
注意:如果是传响应式数据需要.value
4、路由跳转接受参数
vue2中:直接写在onLoad中
onLoad(options){
console.log("接受参数对象",options)
}
vue3中:按需引入,比vue2多一个步骤
import {
onLoad
} from '@dcloudio/uni-app';
onLoad(options){
console.log("接受参数对象",options)
}
更多推荐
所有评论(0)