import { IconDefinition } from '@ant-design/icons-angular'; import { NzIconModule } from 'ng-zorro-antd/icon'; // 引入你需要的图标,比如你需要 fill 主题的 AccountBook Alert 和 outline 主题的 Alert,推荐 ✔️ import { AccountBookFill, AlertFill, AlertOutline } from '@ant-design/icons-angular/icons'; const icons: IconDefinition[] = [ AccountBookFill, AlertOutline, AlertFill ]; // 引入全部的图标,不推荐 ❌ // import * as AllIcons from '@ant-design/icons-angular/icons'; // const antDesignIcons = AllIcons as { // [key: string]: IconDefinition; // }; // const icons: IconDefinition[] = Object.keys(antDesignIcons).map(key => antDesignIcons[key]) @NgModule({ declarations: [ AppComponent ], imports: [ NzIconModule.forRoot(icons) ] bootstrap: [ AppComponent ] }) export class AppModule { }
可能还需要在provider中引入
import { NzIconService } from "ng-zorro-antd/icon"