离子4 +角度:routerLink仅在第一次使用 [英] ionic 4 + angular: routerLink only works first time

查看:67
本文介绍了离子4 +角度:routerLink仅在第一次使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在从头开始开发基本应用程序时遇到了一个奇怪的错误. 我使用的是Ionic 4 beta 19,并且已将routerLink放置到另一个页面,该路由是在基本页面模块中设置的,如下所示:

RouterModule.forChild([
  { path: '', component: NewsPage },
  { path: ':id', component: DetailPage }
])

routerLink属性是在卡上设置的,单击卡时它可以正常工作,但是当我返回并按下同一张卡或另一张卡时,路由器根本不执行任何操作.我没有任何错误,浏览器中的URL正常运行.怎么会这样?

而且,DetailPage没有模块,因此它基本上只是一个页面.

卡代码如下:

<ion-card *ngFor="let item of items;" [routerLink]="[item.id]">
  ...
</ion-card>

在详细信息页面中,订阅了路由参数,并且:id参数将用于GET请求订阅以检索数据

解决方案

此问题已解决,只需运行npm i @ionic/angular即可更新到4.2.0或更高版本.

这也影响了router.navigate(['url', params])功能

I'm having a weird bug while developing a basic app from scratch right now. I use Ionic 4 beta 19 and I've put a routerLink to another page, the route is set up in the base pages module like so:

RouterModule.forChild([
  { path: '', component: NewsPage },
  { path: ':id', component: DetailPage }
])

the routerLink attribute is set on a card and it works just fine when clicking on a card, but when I go back and press that same card or another one, the router just doesn't do anything at all. I don't get any errors and the URL in the browser is working perfectly. How can this be?

Edit: Also, DetailPage doesn't have a module so it's basically just a page.

Edit: Card code looks like this:

<ion-card *ngFor="let item of items;" [routerLink]="[item.id]">
  ...
</ion-card>

In the detail page, route params are subscribed and the :id param will be used for a GET request subscription to retrieve the data

解决方案

This is already fixed, just run npm i @ionic/angular to update to the fixing version 4.2.0 or superior.

This was also affecting router.navigate(['url', params]) functionality

这篇关于离子4 +角度:routerLink仅在第一次使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆