1.生成二维码
使用github开源项目qrcode。
1.引入方式一(js cdn引入):
①.引入qrcode cdn:
自行下载、、没有合适的cdn,地址
<script src="js地址"></script>
②.在dom中插入:
<canvas id="qrcode"></canvas>
③.后加入js配置:
var qrcode = new QRCode.toCanvas(document.getElementById('qrcode'), 'https://www.baidu.com', function(error) {
if (error) console.error(error)
console.log('success!');
})
④.整体代码如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <div> <canvas