[Front-end] JQ generates QR code

Two methods are provided, both of which are generated with the help of JQ plug-in.

Required files: https://download.csdn.net/download/qq_25285531/88204985 icon-default.png?t=N6B9https://download.csdn.net/download/qq_25285531/88204985

method one:

<script type="text/javascript" src="/static/index/js/jquery-1.11.3.min.js" ></script>
<script src="/static/index/js/qrcode.js"></script>

<style type='text/css'>
/*二维码大小*/
  #qrcode img {
      width:90px;
      height:90px;
  } 
</style>

<body>
	<div id="qrcode"></div>
</body>

<script type="text/javascript">
  	$(function(){  
		var qrcode = new QRCode("qrcode");
	    // 生成二维码的方法
	    function makeCode () {     
	        // 二维码地址 
	        var Url = 'www.baidu.com';
	        qrcode.makeCode(Url);
	    }
	    makeCode();
    })
</script>

Method two: relatively simple

<script src="/newadmin/js/jquery-1.12.3.min.js"></script>
<script src="/newadmin/js/jquery.qrcode.min.js"></script>

<body>
    <div id="qrcode"></div>
</body>

<script type="text/javascript">

    // 生成二维码
	jQuery('#qrcode').qrcode({
	    render: "canvas", //也可以替换为table
	    width: 200,
	    height: 200,
	    text: "www.baidu.com"
	});
</script>

Guess you like

Origin blog.csdn.net/qq_25285531/article/details/132223927