如何解决同一网址页面中的 Ionic 5 路由
您好,我想从页面进行路由以转到相同的 url 页面,但具有不同的参数。我猜它不能转到相同的 url 页面,因为我使用路由,它可以很好地转到其他页面,但不能转到同一个 url 页面。这是我目前得到的
profile-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 {}
profile.html
<ion-thumbnail class="story-avatar" [ngClass]="{'seen': false}" (click)="goProfile(item)"
profile.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()
}
解决方法
有几种可能导致错误。试试:
-
在导航行中的应用前添加“/”
-
使用
navigateByUrl
-
像这样分解路径
this.router.navigate(['/','app','tablinks','home','profile'],navigationExtras);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。