1.npm 安装
npm i qrcode
2.页面引用
import QRCode from 'qrcode'
3.页面使用
html
<canvas id="qrcode" style="width: 200px;height: 200px;"></canvas>
方法中使用
var qrcode = document.getElementById('qrcode') QRCode.toCanvas(qrcode,'输入要放到二维码的数据', function (error) { if (error) console.error(error) })