This project was generated with Angular CLI version 8.3.20.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via Protractor.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.
-
angular2-qrcode 生成二维码 (不支持中文)
npm install angular2-qrcode --save
-
JsBarcode 生成条形码
-
把JsBarcode.all.min.js放在assets/libs文件夹下
-
在angular.json文件里引入 JsBarcode.all.min.js
-
使用的组件中加入declare var JsBarcode: any;
注意:要在组件视图初始化加载完才可以调用生成条形码方法,因此生成条形码函数要写在生命周期
ngAfterViewInit
中
-
-
eventemitter3 事件侦听器
npm install eventemitter3 --save
import {EventEmitter} from 'eventemitter3';
const myEmitter = new EventEmitter();
//监听事件event
myEmitter.on('event', function firstListener(arg1, arg2) {
console.log('Helloooo! first listener');
});
//发送事件event
myEmitter.emit('event', 1, 2, 3, 4, 5);