【发布时间】:2021-04-25 18:20:51
【问题描述】:
我正在开发一个 Angular 项目,我想隐藏 URL 中的路径。我不使用导航。这就是我需要的是当我进入站点时只看到www.hgshgs.gr 而不是www.hgshgs.gr/pages/dashboard。有没有办法做到这一点?
page-routing.module.ts
const routes: Routes = [{
path: '',
component: PagesComponent,
children: [
{
path: 'dashboard',
component: ECommerceComponent,
},
{
path: 'iot-dashboard',
component: DashboardComponent,
},
{
path: '',
redirectTo: 'iot-dashboard',
pathMatch: 'full',
},
{
path: '**',
component: NotFoundComponent,
},
],
}];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
【问题讨论】:
-
你说你不使用导航,然后继续显示路由定义。
-
@MichaelD 我的意思是我没有可以在其他组件上导航的按钮。
-
如果不想路由,可以在 app.compoment.html 中使用组件选择器。