歡迎關注github:https://github.com/myopenresources
angular版 二維碼組件cc-qrcode
安裝
npm install cc-qrcode --save 或 yarn add cc-qrcode
使用
// 業務模塊
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { QrcodeModule } from 'cc-qrcode';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
QrcodeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
//業務html
<div>
<cc-qrcode [value]="'123456789'"></cc-qrcode>
</div>
參數
-
value:二維碼值
-
background:背景顏色,默認白色
-
foreground:前景顏色,默認黑色
-
backgroundAlpha:背景透明度
-
foregroundAlpha:前景透明度
-
level:二維碼級別,默認L
-
mime:生成的圖片類型,默認image/png
-
padding:內邊距
-
size:二維碼大小(寬高)
-
canvas:是否使用畫布生成,默認爲false,圖片方式