angularjs - 使用查询参数 ionic 4 以编程方式导航页面
问题描述
我想将数据传递到另一个页面。我的 app-routing.module 是这样的:
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', loadChildren: './home/home.module#HomePageModule' },
{ path: 'web-page/:url', loadChildren: './web-page/web-page.module#WebPagePageModule' },
{ path: 'qrscan', loadChildren: './qrscan/qrscan.module#QrscanPageModule' },
];
使用 HTML 我可以成功传递数据:
<ion-button expand="full" [routerLink]="['/web-page/', urlBooking]" routerDirection="forward">BOOKING</ion-button>
但我在打字稿中苦苦挣扎:
this.router.navigate(['web-page'], { queryParams: { 'url': "https://apple.stackexchange.com/questions/180387/xcode-failed-to-download-use-the-purchases-page-to-try-again" } });
解决方案
你没有说什么不起作用,但你可能想对你的查询参数进行 url 编码。这应该工作得很好。并decodeURIComponent
在您使用该参数的地方使用。
const url = encodeURIComponent("https://apple.stackexchange.com/questions/180387/xcode-failed-to-download-use-the-purchases-page-to-try-again");
this.router.navigate(['web-page'], { queryParams: { url } });
推荐阅读
- reactjs - 在 useEffect 挂钩中进行的异步调用的测试结果
- python - 如何重塑 ndarray,特别是简单的方法 ro (25,25) 到 (1,1)?
- angularjs - 如何在选中复选框时将更改标签变为可见并在未选中时隐藏?
- javascript - 使用 Pre-ES6 语法的自定义元素
- amazon-web-services - 如何对 ECS Fargate 上的容器进行故障排除?
- ruby-on-rails-5 - 如何修复错误:PG::AmbiguousColumn: ERROR: column reference "created_at" is ambiguous
- rust - 如何在 Rust 中为延迟计算的值正确实现缓存结构?
- r - 循环和读取数据框时出现 read_html 问题
- node.js - 需要帮助将我的 ExpressJS 网站上传到 dreamhost VPS
- python - 如何告诉单击始终显示选项默认值