創(chuàng)建項目
參考文章:
https://ng.ant.design/docs/introduce/zh
1卓箫,使用 npm init創(chuàng)建
npm init nx-workspace ng-demo
創(chuàng)建過程
image.png
image.png
以上依賴需要切換到公司服務(wù)器下載
npm install -g nrm
nrm add parim http://npm.parim.net
nrm use parim
@ng-molain/components 還需要添加依賴ng-zorro-antd相赁, cropperjs
cd ng-demo
ng add ng-zorro-antd
npm install cropperjs
npm install ngx-countdown
npm install file-saver
ng add @ng-molain/common
ng add @ng-molain/components
ng add @ng-molain/drag-drop
npm install @antv/g2
npm install @antv/data-set
npm install @antv/g2-plugin-slider
ng add @ng-molain/g2-charts
另外需要在angular.json中引入js如下:
"scripts": [
"node_modules/@antv/g2/build/g2.js",
"node_modules/@antv/data-set/dist/data-set.min.js",
"node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js"
]
image.png
3,創(chuàng)建angular組件庫
ng g @nrwl/angular:library course
因為新創(chuàng)建的模塊名已經(jīng)到基于 baseUrl 的路徑映射的列表中涂圆,所以在應(yīng)用中引入組件應(yīng)
import { CourseModule } from '@ng-demo/course';
4窗宦,創(chuàng)建shared模塊结蟋,包含全局應(yīng)用到的公共模塊寞肖,在tsconfig.json中添加映射路徑似舵,應(yīng)用程序做修、組件庫都可以引入霍狰。
5,打包時報錯
Your global Angular CLI version (8.3.21) is greater than your local
version (8.3.14). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
Generating ES5 bundles for differential loading...
An unhandled exception occurred: Call retries were exceeded
See "C:\Users\EDZ\AppData\Local\Temp\ng-cZbxQ5\angular-errors.log" for further d
etails.
同樣在日志中饰及,提到[錯誤]錯誤:在ChildProcessWorker.initialize中超過了呼叫重試蔗坯,解決方案:在package.json添加"build:demo"腳本為:ng build demo --prod --build-optimizer