【发布时间】:2021-05-06 08:42:07
【问题描述】:
我想对一些路由使用散列(#) 和一些不使用散列(#) 的路由。我该如何实现这一点,例如,想要加载 attendance-report 带有散列和非散列的路径。这是我的 app.module.ts 文件
import { Routes, RouterModule } from "@angular/router";
import { AuthGaurdService } from "./auth/auth-gaurd/auth-gaurd.service";
import { PageNotFoundComponent } from "./dashboard/pages/page-not-found/page-not-found.component";
const routes: Routes = [
{ path: "login", redirectTo: "dashboard", pathMatch: "full" },
{
path: "attendance-report/:token",
loadChildren: () =>
import("./dashboard/pages/agent-attendance/agent-attendance.module").then(
(m) => m.AgentAttendanceModule
),
},
{
path: "",
canActivate: [AuthGaurdService],
children: [
{ path: "", redirectTo: "dashboard", pathMatch: "full" },
{
path: "",
loadChildren: () =>
import("./dashboard/dashboard-layout.module").then(
(m) => m.AdminLayoutModule
),
},
],
},
{ path: "**", component: PageNotFoundComponent },
];
@NgModule({
imports: [
RouterModule.forRoot(routes, {
useHash: true,
relativeLinkResolution: "legacy",
})
],
exports: [RouterModule],
})
export class AppRoutingModule {}
【问题讨论】:
-
您能否分享一下您将如何使用散列和非散列方法的上下文?
标签: javascript angular typescript frontend