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"