AngularMaterial中的mat-list-item与routerLinkActive无法正常工作
创始人
2024-10-28 11:35:39
0
  1. 确保在mat-list中使用mat-list-item组件,并在每个mat-list-item上使用routerLink属性指定导航链接。
  2. 在根模块中导入RouterModule并在imports数组中使用RouterModule.forRoot(routes)配置路由。
  3. 在组件模块中导入RouterModule并在imports数组中使用RouterModule.forChild(routes)配置子路由。
  4. 在模板中的mat-list-item中指定routerLinkActive属性和routerLinkActiveOptions对象,以使选中状态得到正确的应用。

以下是示例代码:

app.module.ts:

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

const routes: Routes = [
  // 定义路由
];

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

component.module.ts:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { MyComponent } from './my.component';

const routes: Routes = [
  // 定义子路由
];

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild(routes)
  ],
  declarations: [
    MyComponent
  ]
})
export class MyComponentModule { }

component.html:


  Home
  About

相关内容

热门资讯

透视有挂(德扑之星猫腻)wep... 透视有挂(德扑之星猫腻)wepoke 软件(详细辅助必胜教程)原生是真的有挂1、德扑之星猫腻ai机器...
wepoke真的有挂!云扑克内... wepoke真的有挂!云扑克内置辅助器,(wepoKe)原来真的有挂(详细辅助科技教程);科技安装教...
透视黑科技(wepoke有挂)... 透视黑科技(wepoke有挂)德扑之星开房间教程(详细辅助靠谱教程)从来是有挂1、许多玩家不知道we...
wepoke辅助挂!德扑之星实... wepoke辅助挂!德扑之星实战,(WPk)原生真的有挂(详细透视攻略方法);wepoke辅助挂软件...
辅助透视(德州ai人工智能)w... 辅助透视(德州ai人工智能)wepoke有正规吗(详细辅助揭秘攻略)从来是真的有挂1、德州ai人工智...
WePoKe透明挂!德扑人工智... 自定义WePoKe透明挂系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不...
透视有挂(智星德州菠萝外挂)约... 透视有挂(智星德州菠萝外挂)约局吧是正规的吗(详细辅助揭秘教程)其实是真的有挂是一款可以让一直输的玩...
wepoke模拟器!gg扑克发... wepoke模拟器!gg扑克发牌好假,(Wpk)本来是有挂(详细辅助解说技巧);支持多人共享记分板与...
透视肯定(wepoke确实有挂... 透视肯定(wepoke确实有挂)fishpoker大菠萝外挂(详细辅助透明教程)原本有挂1)wepo...
微扑克ai机器人!wepoke... 微扑克ai机器人!wepoke软件透明挂,(wepOke)从来存在有挂(详细透视wpk教程)是一款可...