离子4 +角度:routerLink仅在第一次使用

编程入门 行业动态 更新时间:2024-10-26 00:31:30
本文介绍了离子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仅在第一次使用

本文发布于:2023-10-12 21:33:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485961.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:离子   角度   routerLink

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!