1. Keep the current page and jump to the new page uni.navigateTo, you cannot jump to the tabbar page
uni.navigateTo({ url: '/pages/login/login' })
In addition to jumping, this method also supports passing parameters, just add a question mark after the path.
like:
uni.navigateTo({ url: '/pages/detail/detail?id=18&title=详情' })
The id and title are the parameters passed by the page. After reaching the target page, they can be received in onLoad:
onLoad(option) {
console.log(option.id, option.title);
}
In addition, if you want to obtain it in other life cycles under special circumstances, you can use the following methods.
const routes = getCurrentPages(); // 获取所有已经打开的页面,得到是一个数组
const currentPageRoute = routes[routes.length - 1]; // 获取以打开页面的最后一项,即当前页面
console.log(currentPageRoute); // 得到一个对象,里面的options字段里,就是页面传递过来的参数
const currentPageOptions = currentPageRoute.options;
console.log(currentPageOptions.id