Installations
npm install easyqrcodejs
Releases
An All-inclusive, Cross-Browser JavaScript QRCode Generator
Published on 05 Feb 2024
An All-inclusive, Cross-Browser JavaScript QRCode Generator
Published on 06 Nov 2023
An All-inclusive, Cross-Browser JavaScript QRCode Generator
Published on 29 Sept 2023
A feature-rich cross-browser javascript QRCode generator
Published on 28 Dec 2021
A feature-rich cross-browser javascript QRCode generator
Published on 21 Dec 2021
A feature-rich cross-browser javascript QRCode generator
Published on 29 Nov 2021
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
20.9.0
NPM Version
10.3.0
Statistics
741 Stars
107 Commits
155 Forks
23 Watching
1 Branches
5 Contributors
Updated on 26 Nov 2024
Bundle Size
50.36 kB
Minified
16.15 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
1,362,018
Last day
1.4%
2,639
Compared to previous day
Last week
1.6%
13,165
Compared to previous week
Last month
8.6%
57,328
Compared to previous month
Last year
46.8%
515,217
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
4
EasyQRCodeJS
EasyQRCodeJS is a powerful, cross-browser QR code generation library that uses JavaScript and runs on DOM-based client browsers. It can be downloaded directly in the browser. It supports Canvas, SVG, and Table drawing methods. It provides flexible configurations, including dot style, Logo, background image, color, title, and support for binary (HEX) data mode. It is also compatible with Angular, Vue.js, React, Next.js, and Svelte frameworks.
EasyQRCodeJS 是使用 JavaScript 的一个强大的、跨浏览器的二维码生成库。运行在基于 DOM 的客户端浏览器,并能够在浏览器中进行下载。它支持Canvas、SVG和Table绘图方法。提供灵活的配置,包括点样式、Logo、背景图片、彩色,标题和二进制(十六进制)数据模式支持。它还能与Angular、Vue.js、React、Next.js和Svelte框架兼容。
Table of contents
- EasyQRCodeJS
- Table of contents
- Choose what you need
- Feature
- Try It!
- Demo preview
- QR Code Structure
- Installation
- Load
- Basic Usages
- QRCode API
- Download the QRCode Image in the Browser
- Angular Support
- Vue.js Support
- React Support
- Next.js Support
- Svelte Support
- FQA
- Browser Compatibility
- License
- EasyQRCodeJS-Premium
- End
Choose what you need
Project | Support |
---|---|
EasyQRCodeJS | Running with DOM on CLIENT-SIDE . Browser(IE6+, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.), Electron, NW.js, ETC. |
EasyQRCodeJS-NodeJS | Running without DOM on SERVER-SIDE. Save image to file(PNG/JPEG/SVG) or get data url text. NodeJS, Electron, NW.js, ETC. |
EasyQRCode-React-Native | A QRCode generator for React Native. Generate QRCode image or get base64 data url text. |
Feature
-
English
-
Cross-browser support for QR code generation based on HTML5 Canvas, SVG and Table
-
Support unicode character set:
😊❤️👍👨💻 Hello, こんにちは, こんにちは, Γεια, Привет, नमस्ते, สวัสดี, Привіт, سلام, Здравей, ສະບາຍດີ, Përshëndetje, Բարեւ, 你好
-
Download the QRCode image in the browser
-
Required Patterns that support dot style
-
Support for Quiet Zone settings
-
Support custom Position Pattern inner fill and outer border color
-
Support custom Alignment Pattern inner fill and outer border color
-
Support custom Timing Patterns vertical, horizontal color
-
Support Logo images (including transparent PNG images)
-
Support Background Image
-
Support for title, subtitle settings
-
Has no dependencies
-
Support AMD, CMD, CommonJS/Node.js JavaScript modules
-
Angular, Vue.js, React, Next.js, Svelte Support
-
Support binary(hex) data mode
-
Support TypeScript
-
-
中文
-
跨浏览器,支持基于 HTML5 Canvas, SVG 和 Table 的二维码生成
-
支持 Unicode 字符集:
😊❤️👍👨💻 Hello, こんにちは, こんにちは, Γεια, Привет, नमस्ते, สวัสดี, Привіт, سلام, Здравей, ສະບາຍດີ, Përshëndetje, Բարեւ, 你好
-
在浏览器中下载
-
支持点形风格的 Required Patterns
-
支持 Quiet Zone 设置
-
支持自定义 Position Pattern 内填充和外边框颜色
-
支持自定义 Alignment Pattern 内填充和外边框颜色
-
支持自定义 Timing Patterns 垂直,水平颜色
-
支持 Logo 图片(包括背景透明的 PNG 图片)
-
支持 Background Image 背景图片
-
支持标题,副标题设置
-
不依赖任何第三方
-
支持 AMD,CMD, CommonJS/Node.js JavaScript 模块加载规范
-
Angular, Vue.js, React, NEXT.js, Svelte 支持
-
二进制数据模式支持
-
TypeScript 支持
-
Try It!
Demo preview
QR Code Structure
Installation
-
Download install
-
Npm install
1npm install easyqrcodejs
Load
-
Script load
1<script src="<PATH>/easy.qrcode.min.js" type="text/javascript" charset="utf-8"></script> 2
-
AMD load
1require.config({ 2 paths: { 3 QRCode: "<PATH>/easy.qrcode.min" 4 } 5}); 6 7require(["QRCode"], function(QRCode){ 8 9 // Your code... 10 11});
-
Node.js load(For Example, Use in Electron)
1const QRCode = require('<PATH>/easyqrcodejs'); 2 3// Your code...
Basic Usages
1<div id="qrcode"></div> 2 3<script type="text/javascript"> 4 // Options 5 var options = { 6 text: "https://github.com/ushelp/EasyQRCodeJS" 7 }; 8 9 // Create QRCode Object 10 new QRCode(document.getElementById("qrcode"), options); 11</script>
QRCode API
Object
1var qrcode = new QRCode(DOM_object, options_object);
Options
1 var options_object = { 2 // ====== Basic 3 text: "https://github.com/ushelp/EasyQRCodeJS", 4 width: 256, 5 height: 256, 6 colorDark : "#000000", 7 colorLight : "#ffffff", 8 correctLevel : QRCode.CorrectLevel.H, // L, M, Q, H 9 10 // ====== dotScale 11 /* 12 dotScale: 1, // For body block, must be greater than 0, less than or equal to 1. default is 1 13 14 dotScaleTiming: 1, // Dafault for timing block , must be greater than 0, less than or equal to 1. default is 1 15 dotScaleTiming_H: undefined, // For horizontal timing block, must be greater than 0, less than or equal to 1. default is 1 16 dotScaleTiming_V: undefined, // For vertical timing block, must be greater than 0, less than or equal to 1. default is 1 17 18 dotScaleA: 1, // Dafault for alignment block, must be greater than 0, less than or equal to 1. default is 1 19 dotScaleAO: undefined, // For alignment outer block, must be greater than 0, less than or equal to 1. default is 1 20 dotScaleAI: undefined, // For alignment inner block, must be greater than 0, less than or equal to 1. default is 1 21 */ 22 23 // ====== Quiet Zone 24 /* 25 quietZone: 0, 26 quietZoneColor: "rgba(0,0,0,0)", 27 */ 28 29 // ====== Logo 30 /* 31 logo: "../demo/logo.png", // Relative address, relative to `easy.qrcode.min.js` 32 logo: "http://127.0.0.1:8020/easy-qrcodejs/demo/logo.png", 33 logoWidth: 80, // fixed logo width. default is `width/3.5` 34 logoHeight: 80, // fixed logo height. default is `heigth/3.5` 35 logoMaxWidth: undefined, // Maximum logo width. if set will ignore `logoWidth` value 36 logoMaxHeight: undefined, // Maximum logo height. if set will ignore `logoHeight` value 37 logoBackgroundColor: '#fffff', // Logo backgroud color, Invalid when `logBgTransparent` is true; default is '#ffffff' 38 logoBackgroundTransparent: false, // Whether use transparent image, default is false 39 */ 40 41 // ====== Backgroud Image 42 /* 43 backgroundImage: '', // Background Image 44 backgroundImageAlpha: 1, // Background image transparency, value between 0 and 1. default is 1. 45 autoColor: false, // Automatic color adjustment(for data block) 46 autoColorDark: "rgba(0, 0, 0, .6)", // Automatic color: dark CSS color 47 autoColorLight: "rgba(255, 255, 255, .7)", // Automatic color: light CSS color 48 */ 49 50 // ====== Colorful 51 // === Posotion Pattern(Eye) Color 52 /* 53 PO: '#e1622f', // Global Posotion Outer color. if not set, the defaut is `colorDark` 54 PI: '#aa5b71', // Global Posotion Inner color. if not set, the defaut is `colorDark` 55 PO_TL:'', // Posotion Outer color - Top Left 56 PI_TL:'', // Posotion Inner color - Top Left 57 PO_TR:'', // Posotion Outer color - Top Right 58 PI_TR:'', // Posotion Inner color - Top Right 59 PO_BL:'', // Posotion Outer color - Bottom Left 60 PI_BL:'', // Posotion Inner color - Bottom Left 61 */ 62 // === Alignment Color 63 /* 64 AO: '', // Alignment Outer. if not set, the defaut is `colorDark` 65 AI: '', // Alignment Inner. if not set, the defaut is `colorDark` 66 */ 67 // === Timing Pattern Color 68 /* 69 timing: '#e1622f', // Global Timing color. if not set, the defaut is `colorDark` 70 timing_H: '', // Horizontal timing color 71 timing_V: '', // Vertical timing color 72 */ 73 74 // ====== Title 75 /* 76 title: 'QR Title', // content 77 titleFont: "normal normal bold 18px Arial", //font. default is "bold 16px Arial" 78 titleColor: "#004284", // color. default is "#000" 79 titleBackgroundColor: "#fff", // background color. default is "#fff" 80 titleHeight: 70, // height, including subTitle. default is 0 81 titleTop: 25, // draws y coordinates. default is 30 82 */ 83 84 // ====== SubTitle 85 /* 86 subTitle: 'QR subTitle', // content 87 subTitleFont: "normal normal normal 14px Arial", // font. default is "14px Arial" 88 subTitleColor: "#004284", // color. default is "4F4F4F" 89 subTitleTop: 40, // draws y coordinates. default is 0 90 */ 91 92 // ===== Event Handler 93 /* 94 onRenderingStart: undefined, 95 onRenderingEnd: undefined, 96 */ 97 98 // ===== Versions 99 /* 100 version: 0, // The symbol versions of QR Code range from Version 1 to Version 40. default 0 means automatically choose the closest version based on the text length. 101 */ 102 103 // ===== Binary(hex) data mode 104 /* 105 binary: false, // Whether it is binary mode, default is text mode. 106 */ 107 108 // ===== Tooltip 109 /* 110 tooltip: false, // Whether set the QRCode Text as the title attribute value of the QRCode div 111 */ 112 113 // ==== CORS 114 /* 115 crossOrigin: null, // String which specifies the CORS setting to use when retrieving the image. null means that the crossOrigin attribute is not set. 116 */ 117 118 // ===== Drawing method 119 /* 120 drawer: 'canvas', // Which drawing method to use. 'canvas', 'svg'. default is 'canvas' 121 */ 122 123 // ===== UTF-8 without BOM 124 /* 125 utf8WithoutBOM: true 126 */ 127 128}
Option | Required | Type | Defaults | Description | Compatibility |
---|---|---|---|---|---|
Basic options | --- | --- | --- | --- | --- |
text | Y | String | '' | Text | |
width | N | Number | 256 | Width | |
height | N | Number | 256 | Height | |
colorDark | N | String | #000000 | Dark CSS color, rgba(0,0,0,0) | |
colorLight | N | String | #ffffff | Light CSS color, rgba(255,255,255,0) | |
correctLevel | N | Enum | QRCode.CorrectLevel.H | QRCode.CorrectLevel.H QRCode.CorrectLevel.Q QRCode.CorrectLevel.M QRCode.CorrectLevel.L | |
Dot style | --- | --- | --- | --- | --- |
dotScale | N | Number | 1.0 | Dot style scale. Ranges: 0-1.0 | |
dotScaleTiming | N | Number | 1.0 | Dot style scale for timing. Ranges: 0-1.0 | |
dotScaleTiming_V | N | Number | undefined | Dot style scale for horizontal timing. Ranges: 0-1.0 | |
dotScaleTiming_H | N | Number | undefined | Dot style scale for vertical timing. Ranges: 0-1.0 | |
dotScaleA | N | Number | 1.0 | Dot style scale for alignment. Ranges: 0-1.0 | |
dotScaleAO | N | Number | undefined | Dot style scale for alignment outer. Ranges: 0-1.0 | |
dotScaleAI | N | Number | undefined | Dot style scale for alignment inner. Ranges: 0-1.0 | |
Quiet Zone | --- | --- | --- | --- | --- |
quietZoneColor | N | String | rgba(0,0,0,0) | Background CSS color to Quiet Zone | |
Quiet Zone | --- | --- | --- | --- | --- |
quietZone | N | Number | 0 | Quiet Zone size | |
quietZoneColor | N | String | rgba(0,0,0,0) | Background CSS color to Quiet Zone | |
Logo options | --- | --- | --- | --- | --- |
logo | N | String | undefined | Logo Image Path or Base64 encoded image. If use relative address, relative to easy.qrcode.min.js | |
logoWidth | N | Number | width/3.5 | Fixed logo width. | |
logoHeight | N | Number | height/3.5 | fixed logo height. | |
logoMaxWidth | N | Number | undefined | Maximum logo width. if set will ignore logoWidth value. | |
logoMaxHeight | N | Number | undefined | Maximum logo height. if set will ignore logoHeight value. | |
logoBackgroundTransparent | N | Boolean | false | Whether the background transparent image(PNG ) shows transparency. When true , logoBackgroundColor is invalid | |
logoBackgroundColor | N | String | #ffffff | Set Background CSS Color when image background transparent. Valid when logoBackgroundTransparent is false | |
Backgroud Image options | --- | --- | --- | --- | --- |
backgroundImage | N | String | undefined | Background Image Path or Base64 encoded Image. If use relative address, relative to easy.qrcode.min.js | |
backgroundImageAlpha | N | Number | 1.0 | Background image transparency. Ranges: 0-1.0 | |
autoColor | N | Boolean | false | Automatic color adjustment(for data block) | |
autoColorDark | N | String | rgba(0, 0, 0, .6) | Automatic color: dark CSS color | |
autoColorLight | N | String | rgba(255, 255, 255, .7) | Automatic color: light CSS color | |
Posotion Pattern Color options | --- | --- | --- | --- | --- |
PO | N | String | undefined | Global Posotion Outer CSS color. if not set, the defaut is colorDark | |
PI | N | String | undefined | Global Posotion Inner CSS color. if not set, the defaut is colorDark | |
PO_TL | N | String | undefined | Posotion Outer CSS color - Top Left | |
PI_TL | N | String | undefined | Posotion Inner CSS color - Top Left | |
PO_TR | N | String | undefined | Posotion Outer CSS color - Top Right | |
PI_TR | N | String | undefined | Posotion Inner CSS color - Top Right | |
PO_BL | N | String | undefined | Posotion Outer CSS color - Bottom Left | |
PI_BL | N | String | undefined | Posotion Inner CSS color - Bottom Left | |
Alignment Color options | --- | --- | --- | --- | --- |
AO | N | String | undefined | Alignment Outer CSS color. if not set, the defaut is colorDark | |
AI | N | String | undefined | Alignment Inner CSS color. if not set, the defaut is colorDark | |
Timing Pattern Color options | --- | --- | --- | --- | --- |
timing | N | String | undefined | Global Timing CSS color. if not set, the defaut is colorDark | |
timing_H | N | String | undefined | Horizontal timing CSS color | |
timing_V | N | String | undefined | Vertical timing CSS color | |
Title options | --- | --- | --- | --- | --- |
title | N | String | '' | ||
titleFont | N | String | normal normal bold 16px Arial | CSS Font | |
titleColor | N | String | #000000 | CSS color | |
titleBackgroundColor | N | String | #ffffff | CSS color | |
titleHeight | N | Number | 0 | Title Height, Include subTitle | |
titleTop | N | Number | 30 | draws y coordinates. | |
SubTitle options | --- | --- | --- | --- | --- |
subTitle | N | String | '' | ||
subTitleFont | N | String | normal normal normal 14px Arial | CSS Font | |
subTitleColor | N | String | #4F4F4F | CSS color | |
subTitleTop | N | Number | 0 | draws y coordinates. default is 0 | |
Event Handler options | --- | --- | --- | --- | --- |
onRenderingStart(qrCodeOptions) | N | Function | undefined | Callback function when the rendering start. can use to hide loading state or handling. | |
onRenderingEnd(qrCodeOptions, dataURL) | N | Function | undefined | Callback function when the rendering ends. dataURL parameter is the base64 data(canvas drawer) or SVG serialized text(svg drawer) of QRCode image(if not support canvas return null ). | |
Version options | --- | --- | --- | --- | --- |
version | N | Number | 0 | The symbol versions of QR Code range from Version 1 to Version 40 . default 0 means automatically choose the closest version based on the text length. Information capacity and versions of QR Codes NOTE: If you set a value less than the minimum version available for text, the minimum version is automatically used. | |
Tooltip options | --- | --- | --- | --- | --- |
tooltip | N | Boolean | false | Whether set the QRCode Text as the title attribute value of the QRCode div. | |
Binary(hex) data model options | --- | --- | --- | --- | --- |
binary | N | Boolean | false | Whether it is binary mode, default is text mode. | |
CORS options | --- | --- | --- | --- | --- |
crossOrigin | N | String | null | String which specifies the CORS setting to use when retrieving the image. null means that the crossOrigin attribute is not set. 'anonymous' , null . | |
UTF-8 options | --- | --- | --- | --- | --- |
utf8WithoutBOM | N | Boolean | true | Use UTF-8 without BOM. set to false value will use BOM in UFT-8. | |
Drawing method options | --- | --- | --- | --- | --- |
drawer | N | String | canvas | Which drawing method to use. canvas , svg . | Chrome, FF, IE9+. |
Method
-
clear()
1qrcode.clear(); // remove the code.
-
makeCode(text)
1qrcode.makeCode("https://github.com/ushelp/EasyQRCodeJS"); // make another code text.
-
resize(width, height)
1qrcode.resize(480, 480); // Resize the image
-
download(fileName)
1qrcode.download("easyQRCode"); // Download the image or svg file, the filename does not need to include extension, '.png' or '.svg' suffix will be added automatically
Download the QRCode Image in the Browser
For a long time, I have not been included to add a download function to our features, because due to browser environment restrictions, it cannot guarantee to truly fully output the image seen by the user.
On the other hand, I see many user demands related to downloading, and there are also different implementation methods, so I decide to provide a friendly and as fully-featured download implementation as possiable.
However, saving Canvas or SVG images on the client side is subject to many restrictions in the browser environments. For example, if your EasyQRCode image used an external image and there is a cross domain issue, you may be able to see the exernal image in the browser, but actully these images may not be able to be read normally and saved to your download file.
Therefore, if your requirement is to save the QRCode as an image, you may consider using EasyQRCodeJS-NodeJS on the server side to gain more complete control.
1 2<!-- QRCode --> 3<div id="qrcode"></div> 4<!-- Download button --> 5<button id="qrcode_download" onclick="downloadQRcode()" style="display:none">download</button> 6 7 8<script type="text/javascript"> 9 var config = { 10 text: "www.easyproject.cn/donation", 11 //... 12 onRenderingEnd:function(options, dataURL){ 13 // Display your download button after the EasyQRCode is rendered. 14 document.getElementById("qrcode_download").style.display='block'; 15 } 16 } 17 // Initiate EasyQRCode 18 var qrcode = new QRCode(document.getElementById("qrcode"), config); 19 20 function downloadQRcode(){ 21 // Download the png image or svg file 22 // The '.png' or '.svg' suffix will be added to filename automatically 23 var fileName = 'EasyQRCode-file' 24 qrcode.download(fileName); 25 } 26</script>
Angular Support
-
Add dependency
1# install with `npm` 2npm install --save easyqrcodejs 3 4# Alternatively you may use `yarn`: 5yarn add easyqrcodejs
-
[NAME].component.html
1<!-- DOM Element--> 2<div #qrcode></div>
-
Activate
esModuleInterop
in yourtsconfig.json
"esModuleInterop": true,
-
[NAME].component.ts
1import { Component, AfterViewInit, ElementRef, ViewChild } from '@angular/core'; 2import QRCode from 'easyqrcodejs'; 3 4@Component({ 5 selector: 'app-root', 6 templateUrl: './app.component.html', 7 styleUrls: ['./app.component.css'] 8}) 9export class AppComponent implements AfterViewInit{ 10 11 // Your DOM Element 12 @ViewChild('qrcode', {static: false}) qrcode: ElementRef; 13 14 ngAfterViewInit(){ 15 16 // Options 17 var options = { 18 text: "https://github.com/ushelp/EasyQRCodeJS" 19 } 20 21 // Create new QRCode Object 22 new QRCode(this.qrcode.nativeElement, options); 23 24 } 25 26 btnClick(){ 27 // .... 28 } 29 30}
Vue.js Support
-
Add dependency
1# install with `npm` 2npm install --save easyqrcodejs 3 4# Alternatively you may use `yarn`: 5yarn add easyqrcodejs
-
Template
1<!-- DOM Element--> 2<div ref="qrcode"></div>
-
Script
1<script> 2import * as QRCode from 'easyqrcodejs' 3 4export default { 5 6 mounted(){ 7 // Options 8 var options = { 9 text: "https://github.com/ushelp/EasyQRCodeJS" 10 } 11 12 // Create new QRCode Object 13 new QRCode(this.$refs.qrcode, options); 14 }, 15 methods:{ 16 btnClick(){ 17 18 } 19 } 20} 21</script>
React Support
-
Add dependency
1# install with `npm` 2npm install --save easyqrcodejs 3 4# Alternatively you may use `yarn`: 5yarn add easyqrcodejs
-
Script
-
JavaScript
1import React from 'react'; 2import './App.css'; 3import * as QRCode from 'easyqrcodejs'; 4 5class App extends React.Component { 6 7 constructor(props) { 8 super(props); 9 this.qrcode = React.createRef(); 10 } 11 12 componentDidMount() { 13 // Options 14 var options = { 15 text: "https://github.com/ushelp/EasyQRCodeJS" 16 } 17 // Create new QRCode Object 18 new QRCode( this.qrcode.current, options); 19 } 20 render() { 21 return ( 22 <div className = "App"> 23 <div ref={this.qrcode}></div> 24 </div> 25 ); 26 } 27} 28 29export default App;
-
TypeScript
1import React, { useEffect } from "react"; 2import QRCode from "easyqrcodejs"; 3 4function App() { 5 const code = React.createRef<HTMLDivElement>(); 6 7 useEffect(() => { 8 new QRCode(code.current, { text: "https://github.com/ushelp/EasyQRCodeJS" }); 9 }, [code]); 10 11 return ( 12 <div className="App"> 13 <header className="App-header"> 14 15 <div ref={code}></div> 16 </header> 17 </div> 18 ); 19} 20 21export default App;
-
Next.js Support
-
Add dependency
Add
easy.qrcode.min.js
to your static files folder calledstatic
(<
Next.js 9.1)/public
(>=
Next.js 9.1) in the root directory. -
Script
1import Layout from '../components/Layout'; 2// Import Head 3import Head from "next/head"; 4 5class About extends React.Component { 6 constructor(props) { 7 super(props); 8 // QRCode DOM 9 this.qrcodeDOM = React.createRef(); 10 // QRCode 11 this.qrcode=null; 12 } 13 14 //QRCode generator 15 generate(color){ 16 if(this.qrcode){ 17 this.qrcode.clear(); 18 } 19 var options = { 20 text: "https://github.com/ushelp/EasyQRCodeJS", 21 colorDark : color?color:'#000000' 22 }; 23 this.qrcode=new QRCode(this.qrcodeDOM.current, options); 24 } 25 26 // Gerenate QRCode on mount 27 componentDidMount() { 28 this.generate() 29 } 30 31 render() { 32 return ( 33 <Layout> 34 <p>This is About page</p> 35 {/* DOM */} 36 <div ref={this.qrcodeDOM}></div> 37 {/* Gerenate QRCode on click */} 38 <button onClick={this.generate.bind(this, '#ff0000')}>QRCode Generate</button> 39 {/* Include EasyQRCodeJS library*/} 40 <Head> 41 <script type="text/javascript" src="/public/easy.qrcode.min.js"></script> 42 </Head> 43 <p>This is About page</p> 44 </Layout> 45 ); 46 } 47} 48 49export default About;
Svelte Support
-
Add dependency
1# install with `npm` 2npm install --save-dev easyqrcodejs 3 4# Alternatively you may use `yarn`: 5yarn add easyqrcodejs --dev
-
Component template
QR.svelte:
1<script> 2 import { onMount } from 'svelte'; 3 import QRCode from 'easyqrcodejs' 4 // import * as QRCode from 'easyqrcodejs'; 5 6 export let codeValue; 7 let node; 8 9 onMount(() => { 10 const options = { 11 text: codeValue, 12 // ... your other options 13 width: 100, 14 height: 100, 15 quietZone: 10, 16 }; 17 new QRCode(node, options); 18 }); 19</script> 20 21<div bind:this={node}></div> 22 23<style> 24 div { 25 /* make QR-wrapper squared */ 26 width: 100%; 27 position: relative; 28 padding: 50%; 29 z-index: 1; 30 } 31 div :global(canvas) { 32 /* fit QR to wrapper */ 33 width: 100%; 34 height: 100%; 35 position: absolute; 36 left: 0; 37 top: 0; 38 } 39</style>
-
Layout
index.svelte:
1<script> 2 import QR from './QR.svelte'; 3</script> 4 5<div class="qr-container"> 6 <QR text="Your awesome text here..." /> 7</div> 8 9<style> 10 .qr-container { 11 /* your styles for container here */ 12 } 13</style>
FQA
Q1. Tainted canvases may not be exported.
When use canvas drawer, Canvas toDataURL function does not allow load cross domain image. there are three options to slove this problem:
-
Option 1:
Configure the
crossOrigin
attribute(crossorigin) for the image. Make sure that CORS is configured on the Server side.1{ 2 // ... 3 4 // String which specifies the CORS setting to use when retrieving the image. null means that the crossOrigin attribute is not set. 'anonymous', null. 5 crossOrigin : 'anonymous', 6 7 // ... 8}
-
Option 2:
Put your image under the same domain with your page.
-
Option 3:
Use base64 image.
Q2. How to show the QRCode image only after rendering is done?
1onRenderingStart: function(qrCodeOptions) { 2 qrCodeOptions._element.style.display = 'none'; 3}, 4onRenderingEnd: function(qrCodeOptions) { 5 qrCodeOptions._element.style.display = 'block'; 6},
Browser Compatibility
IE6+, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.
License
MIT License
EasyQRCodeJS-Premium
Let you draw freely!
EasyQRCodeJS-Premium is a more powerful and comprehensive enterprise version. You can use Canvas to customize any element, such as eye frame shape, eyeball shape, QR code block shape, and more. Also supports excavation (to prevent the QRcode overlap with the logo), random block mode.
If you need more functions, we can provide you with customized development of API libraries or products. please contact me to buy the business enterprise edition.
EasyQRCodeJS-Premium 是功能更加强大和全面的商业/企业版本。让您可以在 QRCode 中通过 Canvas 自定义任何喜欢的元素,例如 Eye frame 形状, Eye ball 形状, QR Body block 形状等等。 还支持 Logo 挖取(excavation,防止二维码与 Logo 重叠)和 Random bolock mode.
如果您需要更多功能,我们可以为您提供 API 库或产品的定制开发。请联系我购买商业/企业版本。
End
Email:inthinkcolor@gmail.com
Donation/捐助:
我们相信,每个人的点滴贡献,都将是推动产生更多、更好免费开源产品的一大步。
感谢慷慨捐助,以支持服务器运行和鼓励更多社区成员。
We believe that the contribution of each bit by bit, will be driven to produce more and better free and open source products a big step.
Thank you donation to support the server running and encourage more community members.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to easyqrcodejs
easyqrcodejs-nodejs
NodeJS QRCode generator. Can save image or svg to file, get standard base64 image data url text or get SVG serialized text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. suppo
@frex/easyqrcodejs
A fork of feature-rich cross-browser QRCode generator EasyQRCodeJs for pure javascript. Support Dot style, Dot shape, Logo, Background image, Colorful, Title, etc. Support Angular, Vue.js, React framework.(Running with DOM on client side)
easyqrcode-react-native
React Native QRCode generation component. Can get standard base64 image data url text or save image to file. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.
easyqrcodejs-arm
A feature-rich cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title, etc. Support Angular, Vue.js, React, Next.js framework.(Running with DOM on client side)