JQuery生成二维码 火推

此项目源码地址:https://github.com/1350048638/comJqueryQRCode
参考官方文档:https://github.com/jeromeetienne/jquery-qrcode


新建
Dynamic Web Project工程

这里写图片描述


放入js文件
jquery-3.2.1.min.js
jquery.qrcode.min.js


新建jsp文件
注意导入的jquery版本,版本低的话显示不了二维码,
js文件顺序不能乱

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
 <head>
    <title>生成二维码</title>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-3.2.1.min.js"></script> <!-- //两个js文件的顺序不能乱, jquery版本要注意-->
    <script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.qrcode.min.js"></script> <!-- //这个是基于jquery开发的 -->
  </head>
  <body>
  生成的二维码如下<br>
  <div id="qrcode" style="height:300px;width:300px"></div>
    <div id="code"> </div>

  <script type="text/javascript">

  jQuery(function(){
        jQuery('#qrcode').qrcode("www.baidu.com"); //打开的是文本,如果需要打开网址,加上 http:// 即可

   $("#code").qrcode({
            render: "table", //table方式
            width: 200, //宽度
            height:200, //高度
            text: "www.qq.com" //任意内容
        });
    })

  </script>
  </body>
</html>

结果

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值