使用JS 插件qrcode.js生成二維碼功能
更新時間:2017年02月20日 16:17:54 作者:Java軟件小白
qrcode.js是一個使用比較多的js生成二維碼的插件,非常方便,接下來通過本文給大家分享使用JS 插件qrcode.js生成二維碼功能,需要的朋友參考下
效果圖:

qrcode.js這是一個使用比較多的js生成二維碼的插件,使用也很方便,第一次用,記錄一下使用方法;
首先,導(dǎo)入js,這個網(wǎng)上可以找到,附上地址:https://github.com/davidshimjs/qrcodejs/
jsp:
<script type="text/javascript" src="<%=basePath %>bootstrap/js/qrcode.js" charset="UTF-8"></script>
<input type="hidden" id="content" value="" />
<!-- 二維碼彈出框 -->
div class="modal fade" id="myModal_qrcode" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">二維碼</h4>
</div>
<div class="modal-body">
<center>
<div id="qrcode"></div>
<table>
<tbody>
<tr>
<td>
<label class="col-sm-4 control-label" for="equ_name_qrcode"><h7>設(shè)備名稱:</h7></label>
<div class="col-sm-8">
<input class="form-control" id="equ_name_qrcode" type="text"/>
</div>
</td>
<td>
<label class="col-sm-4 control-label" for="equ_ip_qrcode"><h7>設(shè)備IP:</h7></label>
<div class="col-sm-8">
<input class="form-control" id="equ_ip_qrcode" type="text"/>
</div>
</td>
</tr>
</tbody>
</table>
</center>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>關(guān)閉
</button>
<button type="button" id="btn_print" class="btn btn-primary" data-dismiss="modal">
<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>打印
</button>
</div>
</div>
</div>
/div>
js:
// 二維碼對象
var qrcode;
function showCode(id) {
var rowid=$("#grid-table").jqGrid("getGridParam","selrow");
if (rowid != null) {
var rowData = $("#grid-table").jqGrid('getRowData',rowid);
// 獲取內(nèi)容
$("#content").val("公司名稱:"+rowData.companyName+","+"設(shè)備IP:"+rowData.deviceIP+","+"投運時間:"+rowData.inTime);
$("#equ_name_qrcode").val(rowData.deviceName);
$("#equ_ip_qrcode").val(rowData.deviceIP);
} else {
toastr.error("點擊錯誤,請重新點擊");
return;
}
// 清除上一次的二維碼
if(qrcode){
$("#qrcode").html("");
}
// 創(chuàng)建二維碼
qrcode = new QRCode(document.getElementById("qrcode"), {
width : 150,//設(shè)置寬高
height : 150
});
$("#myModal_qrcode").modal();
// $(".btn_print").attr('id','btn_print'+id);
qrcode.makeCode(document.getElementById("content").value);
}
以上所述是小編給大家介紹的使用JS qrcode.js生成二維碼功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
淺談layui 綁定form submit提交表單的注意事項
今天小編就為大家分享一篇淺談layui 綁定form submit提交表單的注意事項,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10
基于JavaScript代碼實現(xiàn)pc與手機之間的跳轉(zhuǎn)
本文通過一段代碼實例給大家介紹pc跳轉(zhuǎn)手機代碼,手機跳轉(zhuǎn)pc網(wǎng)站代碼的相關(guān)知識,對js跳轉(zhuǎn)代碼相關(guān)知識感興趣的朋友一起通過本篇文章學習吧2015-12-12
(推薦一個超好的JS函數(shù)庫)S.Sams Lifexperience ScriptClassLib
(推薦一個超好的JS函數(shù)庫)S.Sams Lifexperience ScriptClassLib...2007-04-04

