简体   繁体   English

为什么使用 routerLink 指令的角度路由器重新加载页面?

[英]Why angular router reload page with routerLink directive?

I did a migration from Angular 10 to 13 and Ionic 5 to 6.我做了从 Angular 10 到 13 和 Ionic 5 到 6 的迁移。

With my current set-up (Angular 13, Ionic 6), I have a strange behavior: when I navigate to new page using routerLink directive, the new page reload and the page stack is lose.使用我当前的设置(Angular 13,Ionic 6),我有一个奇怪的行为:当我使用 routerLink 指令导航到新页面时,新页面重新加载并且页面堆栈丢失。

The behavior is the same as user typing directly the URL in navigator bar.该行为与用户在导航栏中直接键入 URL 相同。

I tried to find similar issue or way to understand this behavior but nothing.我试图找到类似的问题或方法来理解这种行为,但没有。

Can you help me please ?你能帮我吗 ?

Router Root configuration:路由器根配置:

    RouterModule.forRoot(routes, {
      preloadingStrategy: PreloadAllModules,
      anchorScrolling: 'enabled',
      enableTracing: false,
      relativeLinkResolution: 'legacy'
    })

Link button integration:链接按钮集成:

<ion-button [routerLink]="['/dashboard/targets']" [queryParams]="{s: 'community'}" ...>...</ion-button>

Router Child configuration:路由器子配置:

    RouterModule.forChild([
      {
        path: 'targets',
        loadChildren: () => import('./targets/targets.module').then( m => m.DashboardTargetsPageModule)
      }
    ]),

Ionic 6 中有一个错误,在 Ionic 6.0.16 中已解决,请尝试安装该版本。

npm install @ionic/angular@6.0.16

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM