jsBarcode:
https://lindell.me/JsBarcode/#
qrcodejs:
https://github.com/davidshimjs/qrcodejs
HTML
<div id="qrcode" ref="qrcode" style="margin: 10px;"></div> <svg id="barcode"></svg>
script
<script src="js/qrcode.js"></script> <script src="js/jsbarcode.js"></script>
JS
methods: { qrCode (url) { // 二维码 let qrcode = new QRCode('qrcode', { width: 180, height: 180, correctLevel : QRCode.CorrectLevel.H }) qrcode.clear() //清除二维码 qrcode.makeCode(url) //生成另一个新的二维码 // 条形码 JsBarcode("#barcode", url,{ height: 50, width: 2.2, fontSize: 14 }); } }, mounted () { this.qrCode('123456789') }
效果: