Home > Back-end >  Jquery. Qrcode. Js generated after the qr code to image format with logo logo, leaders help to look
Jquery. Qrcode. Js generated after the qr code to image format with logo logo, leaders help to look

Time:10-19

 & lt; Div & gt; 







 
The $(document). Ready (function () {
Var qrcode=$(" # qrcode "). Qrcode ({
Render: "canvas",//set the render mode, a table and canvas, use canvas rendering performance is relatively good
Text: 'http://jcp.natapp1.cc/gene_detection/authorization.html? OpenId='+ sessionStorage. The getItem (" openId "),//
After scanning the qr code display content, can fill a url directly, after scanning the qr code automatically jump to the link
Width: "200",//the width of the qr code
Height: "200",//the height of the qr code
Background: "# FFFFFF",//scenery of qr code after
Foreground: "# 000000",//the foreground of qr code
SRC: 'http://jcp.natapp1.cc/gene_detection/image/logo.jpg'//qr code in the middle of the picture
}). Hide ();
Var canvas=qrcode. Find (' canvas'). The get (0);
The console. The log (qrcode. Find (' canvas'));
Var data=https://bbs.csdn.net/topics/canvas.toDataURL (' image/JPG);
$(' # img). Attr (' SRC 'data);

CodePudding user response:


<script language="JavaScript" & gt;
$(function () {
Var options={
Render: "canvas,"
EcLevel: 'H',//recognition
The fill: '# 000',//qr code color
Background: # FFFFFF,//background color
Quiet: 2,//margin
Width: 200,//width
Height: 200,
Text: "http://www.whui.org",//qr code content
//the middle logo start
Mode: 4,
MSize: 11 * 0.01,
MPosX: 50 * 0.01,
MPosY: 50 * 0.01,
Image: $(' # img - buffer) [0],//logo picture
//the middle logo end
Label: 'jQuery. Qrcode,
Fontname: 'Ubuntu,
Fontcolor: '# ff9818',
};
$(' # container). The empty (). The qrcode (options);
})
</script>
Note:

Add the logo in the middle of the time,

The embedded logo img object & lt; Img SRC="" & gt; , direct logo url and useless, will error out directly, must be in the form of img tags,

When the render is canvas, img SRC for the same domain
When the render is image, img SRC must be the same domain, otherwise it will result in an error because of cross-domain problem

CodePudding user response:

The building Lord, this problem solved?

CodePudding user response:

Logo is not because of your logo image cross-domain, the images must be found in the source code to generate logo function, add img. SetAttribute (' crossOrigin ', 'anonymous')
  • Related