HTML img 标签 二维码显示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div class="container">
<div class="row navContent">
</div>
</div>
<!-- 二维码是 base64的图片 需要注意字符串转义问题 \n \r 等 反转义-->
<img src="https://img-blog.csdnimg.cn/2022010618552372051.png" alt="流氓兔-">
<script src="js/jquery.min.js"></script>
<script>
$(function() {
<!-- 方式二 有js跨域的问题,最好是服务端允许跨域 -->
var url ="http://localhost:8080";
$.ajax({
url: url + "/tools/qrCode.json",
type: "get",
data: {
"text" : "测试",
"encode" : 0
},
success: function (data) {
console.log(data);
var html = "";
html += '<img href="#" src="https://img-blog.csdnimg.cn/2022010618552481744.png' + data.data.qrCode+ '" alt="code">';
html += '<br><span>' + data+ '</span>';
console.log(html);
$(".navContent").html(html);
},
error: function (data) {
if (data.code == "500") {
$("#asdasd").load("content/500.html")
} else if (data.code == "404") {
$("#asdasd").load("content/404.html")
}
layer.closeAll();
}
})
});
</script>
</body>
</html>