vue生成條形碼和二維碼

條形碼:

使用jsbarcode:

官網(wǎng):

https://lindell.me/JsBarcode/

簡單使用如下:

vue用法:

1.npm install jsbarcode --save

2.在需要使用的vue頁面里面引用:

import JsBarcode from 'jsbarcode'

3.界面中使用:

<div? style="text-align: center;" ><svg id="barcode" ></svg></div>

4.js:

JsBarcode("#barcode", "123456789",{ fontSize:14, });

詳細(xì)參數(shù)參考官方文檔。

二維碼:

使用qrcodejs2:

沒有找到官網(wǎng),可以參考npmjs:

https://www.npmjs.com/package/qrcodejs2

vue用法:

1.npm install qrcodejs2 --save

2.在需要使用的頁面中引用:

import QRCode from 'qrcodejs2'

3.頁面:

<div style="display: flex;justify-content: center;" id='qrcode'></div>

4.js:

if(!this.qrCode){
this.qrCode = new QRCode('qrcode', { width: 150, height: 150, })??
?this.qrCode.clear();
var QRCodeStr = "123456789";?
?this.qrCode.makeCode(QRCodeStr);?

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容