我想将数据传递到另一个页面。 我的 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>
但是我很难用 typescript 来做:
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 } });
关于angularjs - 使用查询参数 ionic 4 以编程方式导航页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55517457/