繁体   English   中英

同一 url 页面中的 Ionic 5 路由

[英]Ionic 5 routing in same url page

您好,我想从一个页面路由到 go 到相同的 url 页面但具有不同的参数。 我猜它不能 go 到相同的 url 页面,因为我使用路由并且它可以很好地转到其他页面,但不能到相同的 url 页面。 这是我到目前为止得到的

配置文件-routing.page.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { ProfilePage } from './profile.page';

  const routes: Routes = [
  {
    path: '',
    component: ProfilePage
  }
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ProfilePageRoutingModule {}

配置文件.html

<ion-thumbnail class="story-avatar" [ngClass]="{'seen': false}" (click)="goProfile(item)"

个人资料.ts

 goProfile(profile: any) {
this.userData.profileViewed(profile).pipe(
  map((data: any) => {
    if (data.success) {
      const navigationExtras: NavigationExtras = {
        state: {
          profile: profile
        }
      };
     this.router.navigate(['app/tablinks/home/profile'], navigationExtras);
    }
  })
).subscribe()
}

有几种可能会导致错误。 尝试:

  1. 在导航行中的应用程序之前添加“/”

  2. 使用navigateByUrl

  3. 像这样打破道路

    this.router.navigate(['/', 'app', 'tablinks', 'home', 'profile'], navigationExtras);

暂无
暂无

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

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