uni.showModal({
title: '温馨提示',
content: '您还未登录,请登录后再试',
confirmText: '去登录',
confirmColor: '#a1afc9',
success({ confirm }) {
const routes = getCurrentPages();
const path = `/${routes[routes.length - 1].route}`;
const options = routes[routes.length - 1].options;
const params = {
path,
options
};
console.log('options=' JSON.stringify(options));
const pagePath = `/pages/packageB/login/login?path=${JSON.stringify(params)}`;
console.log('pagePath=', pagePath);
}
});
- 发布:2023-08-01 11:56
- 更新:2023-08-01 11:56
- 阅读:222
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 19045.2251
HBuilderX类型: 正式
HBuilderX版本号: 3.8.7
手机系统: Android
手机系统版本号: Android 14
手机厂商: 小米
手机机型: 小米12
页面类型: nvue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
uni.showModal({
title: '温馨提示',
content: '您还未登录,请登录后再试',
confirmText: '去登录',
confirmColor: '#a1afc9',
success({ confirm }) {
const routes = getCurrentPages();
const path = `/${routes[routes.length - 1].route}`;
const options = routes[routes.length - 1].options;
const params = {
path,
options
};
console.log('options=' JSON.stringify(options));
const pagePath = `/pages/packageB/login/login?path=${JSON.stringify(params)}`;
console.log('pagePath=', pagePath);
}
});
uni.showModal({
title: '温馨提示',
content: '您还未登录,请登录后再试',
confirmText: '去登录',
confirmColor: '#a1afc9',
success({ confirm }) {
const routes = getCurrentPages();
const path = `/${routes[routes.length - 1].route}`;
const options = routes[routes.length - 1].options;
const params = {
path,
options
};
console.log('options=' JSON.stringify(options));
const pagePath = `/pages/packageB/login/login?path=${JSON.stringify(params)}`;
console.log('pagePath=', pagePath);
}
});
预期结果:
/pages/packageB/login/login?path={"path":"/pages/packageB/case-detail/case-detail?id=1"}
/pages/packageB/login/login?path={"path":"/pages/packageB/case-detail/case-detail?id=1"}
实际结果:
/pages/packageB/login/login?path={"path":"/pages/packageB/case-detail/case-detail"}
/pages/packageB/login/login?path={"path":"/pages/packageB/case-detail/case-detail"}
bug描述:
在安卓开发中,使用getCurrentPages获取参数时无法获取options参数,在微信小程序中可以正常获取
0 个回复