要用H5生成二维码:

1.引入js库,可自行点击链接复制使用

1 <script type="text/javascript" src="http://static.runoob.com/assets/qrcode/qrcode.min.js"></script>

 

2.加入二维码占位区HTML

1 <div id="code"></div>

 

3.设置宽度和高度,在makeCode函数中传入链接,即可生成成功。

1 var qrcode = new QRCode(document.getElementById("code"), {
2 width : 201,
3 height : 201
4 })
5
6 var url = location.href
7 qrcode.makeCode(url.replace("invitation","main"))