标签:text com global path codec var png ati 扫码
//js引用部分
<script src="../qrcode.js" type="text/javascript"></script>
//body部分
<div class="qrcode-canvas" style="display: none;"></div>
<div class="qrcode-box">
<img src="" class="qrcode hide">
<div><img src="../common/images/logo.png" class="icon"></div>
</div>
//js部分
//设置二维码跳转的url
var QrUrl = location.origin+global.basePath+‘/dance/danceAddMember.html?teamId=‘+data.content.teamId;
//设置手动添加跳转的url
$(‘.dance-add-member-box .add-btn‘).attr(‘href‘,QrUrl);
//使用canvas生成二维码
var qrcodeCanvas = $(‘.qrcode-canvas‘);
qrcodeCanvas.qrcode({correctLevel: 0,text:QrUrl}).hide();
//获取canvas对象
var canvas = qrcodeCanvas.find(‘canvas‘).get(0);
//转换base输出到img中
$(‘.qrcode-box .qrcode‘).attr(‘src‘,canvas.toDataURL(‘image/jpg‘)).show();
标签:text com global path codec var png ati 扫码
原文地址:https://www.cnblogs.com/xieyongbin/p/9685908.html