<input type="file" id="input">
<button id="button">获取内容</button>
<!--引入js文件-->
<script src="<?= PublicUtil::URL('@web/js/qrcode/analysis-qrcode.js')?>"></script>
<script type="text/javascript">
//获取预览图片路径
var getObjectURL = function(file){
var url = null ;
if (window.createObjectURL!=undefined) { // basic
url = window.createObjectURL(file) ;
} else if (window.URL!=undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file) ;
} else if (window.webkitURL!=undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file) ;
}
return url ;
};
$("#button").click(function () {
var content = document.getElementById("input").files[0];
qrcode.decode(getObjectURL(content));
qrcode.callback = function(imgMsg){
alert(imgMsg);
};
});
</script>
js识别图片二维码解析网址代码
最新推荐文章于 2024-08-15 14:44:33 发布