下面的配置中有一些我不完全理解的问题。
要求
问题
我有一个菜单组件,通过整个应用程序都可以看到它,我有一个指向设置页面的链接。激活此页面后,可以很好地应用活动类。
Menu.html
<a[routerLink]="['/settings']" routerLinkActive="active"> Settings </a>
router.module
{
path: 'settings',
loadChildren: () => import('../app/settings/settings.module').then(mod => mod.SettingsModule),
},
settings.module
const routes: Routes = [
{
path: '',
component: SettingsComponent,
children: [
{
path: 'account',
loadChildren: () => import('account.module').then(mod => mod.AccountModule),
},
],
}
]
settings.html
在我的settings.html中,我有两个子菜单链接和一个路由器插座,单击链接后即可显示模块
<a [routerLink]="['/settings/account']" routerLinkActive="active">
<a [routerLink]="['/settings/test']" routerLinkActive="active">
<router-outlet></router-outlet>
注释 :最初,我考虑仅从主菜单链接链接到/settings/account
。可以使用正确的着陆网址的预期结果,并显示设置html和帐户html。这里的问题是,如果我要在settings.html中单击settings/test
,则会在主菜单上删除routerLinkActive类。