ionic 4 + angular:routerLink 只在第一次工作 [英] ionic 4 + angular: routerLink only works first time

查看:26
本文介绍了ionic 4 + angular:routerLink 只在第一次工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 }
])

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

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?

此外,DetailPage 没有模块,所以它基本上只是一个页面.

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

卡片代码如下所示:

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

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

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

推荐答案

这个已经修复了,只需运行 npm i @ionic/angular 即可更新到修复版本 4.2.0 或更高版本.

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

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

这篇关于ionic 4 + angular:routerLink 只在第一次工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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