<div style="margin:1.3rem auto;">
<div class="codesize" style="width:25%;margin:0 auto; border:1px solid #f6f6f9">
<div id="qrcode"></div>
</div>
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js" ></script>
<script type="text/javascript" src="__TPL__/js/qrcode.js"></script>
<input id="text" type="hidden" value="{$ticketurl}" style="width:80%" /><br/>
<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
width : 100,
height : 100
});
function makeCode () {
var elText = document.getElementById("text");
if (!elText.value) {
alert("Input a text");
elText.focus();
return;
}
qrcode.makeCode(elText.value);
}
makeCode();
$("#text").
on("blur", function () {
makeCode();
}).
on("keydown", function (e) {
if (e.keyCode == 13) {
makeCode();
}
});
</script>
另外在导入的css中添加,注意要是导入的css(好像可以不用,先跳下一步)
.codesize img{width:100%;} //控制图片大小
还有这句的width和margin-left是调整图片大小和位置的
<div class="codesize" style="width:55%;margin-left: 8rem; border:1px solid #f6f6f9">
还有赋值
$ticketurl = __URL__ . '/?m=default&c=user&a=deleteTicket&ticket_id=' . $ticket_id;
$this->assign('ticketurl', $ticketurl);
<input id="text" type="hidden" value="{$ticketurl}" style="width:80%" /><br/>