qrcode生成二维码

发布时间 2023-08-06 18:24:57作者: kgwei

js qrcode 包生成二维码

  • 安装
npm install --save qrcode
  • 或者,全局安装以便从命令行保存qrcode图像或生成您可以在您的终端中查看的图像。
npm install -g qrcode 
  • 使用
import QRCode from "qrcode"
let code = "string....";

QRCode.toDataURL(code,{
    errorCorrectionLevel:"H",
	width:200,
	height:200,
}).then(res=>{
    console.log(res);
	this.qrImg = res; //二维码的 base64 字符串
})