ng-zorro-antd 入門

  1. ng new tk-zorro-web --skip-install --style=scss
  2. cd tk-zorro-web
  3. npm i
  4. npm install --save ng-zorro-antd
  5. ng serve --port 4201
  • // 下載https://ng.ant.design/assets/download/fonts.zip

// 解壓到:/assets/fonts/css

  • // /src/app/app.module.ts

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgZorroAntdModule } from 'ng-zorro-antd';html

@NgModule({
  imports: [
    BrowserAnimationsModule,
    NgZorroAntdModule.forRoot({ extraFontName: 'anticon', extraFontUrl: './assets/fonts/iconfont' })
  ]
})web

  • // /src/app/app.component.html

<button nz-button [nzType]="'primary'">測試按鈕</button>npm

  • // /src/shared/shared.module.ts

ng g m sharedantd

import { NgZorroAntdModule } from 'ng-zorro-antd';app

@NgModule({
  imports: [
    NgZorroAntdModule
  ], exports: [
    NgZorroAntdModule
  ]
})測試

  • // /src/monitor/monitor.module.ts

ng g m monitorcomponent

import { SharedModule } from '../shared';orm

@NgModule({
  imports: [
    SharedModule
  ]
})htm

  • // /src/monitor/monitor-layout/monitor-layout.component.html

ng g c monitor/monitor-layout

<button nz-button [nzType]="'primary'">測試按鈕</button>

相關文章
相關標籤/搜索