|
1 | 1 | # EasyQRCodeJS |
2 | 2 |
|
3 | | -EasyQRCodeJS is a feature-rich cross-browser pure JavaScript QRCode generation library. Support Canvas, SVG and Table drawing methods. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support Angular, Vue.js, React, Next.js framework. Support binary(hex) data mode.(Running with DOM on client side) |
| 3 | +EasyQRCodeJS is a feature-rich cross-browser pure JavaScript QRCode generation library. Support Canvas, SVG and Table drawing methods. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support Angular, Vue.js, React, Next.js, Svelte framework. Support binary(hex) data mode.(Running with DOM on client side) |
4 | 4 |
|
5 | | -EasyQRCodeJS 是一个功能丰富的跨浏览器的纯 JavaScript QRCode 生成库。支持 Canvas, SVG, Table 等绘制方式。支持 JavaScript 模块化加载。支持点状风格,Logo,背景图片,规则色彩控制,标题等设置。支持 Angular, Vue.js, React, Next.js 等框架。支持二进制数据模式。(基于客户端 DOM 运行) |
| 5 | +EasyQRCodeJS 是一个功能丰富的跨浏览器的纯 JavaScript QRCode 生成库。支持 Canvas, SVG, Table 等绘制方式。支持 JavaScript 模块化加载。支持点状风格,Logo,背景图片,规则色彩控制,标题等设置。支持 Angular, Vue.js, React, Next.js, Svelte 等框架。支持二进制数据模式。(基于客户端 DOM 运行) |
6 | 6 |
|
7 | 7 |
|
8 | 8 | ## Table of contents |
9 | 9 |
|
10 | | -- [Choose what you need](#choose-what-you-need) |
11 | | -- [Feature](#feature) |
12 | | -- [Try It!](#try-it) |
13 | | -- [Demo preview](#demo-preview) |
14 | | -- [QR Code Structure](#qr-code-structure) |
15 | | -- [Installation](#installation) |
16 | | -- [Load](#load) |
17 | | -- [Basic Usages](#basic-usages) |
18 | | -- [QRCode API](#qrcode-api) |
19 | | - - [Object](#object) |
20 | | - - [Options](#options) |
21 | | - - [Method](#method) |
22 | | -- [Angular Support](#angular-support) |
23 | | -- [Vue.js Support](#vuejs-support) |
24 | | -- [React Support](#react-support) |
25 | | -- [Next.js Support](#nextjs-support) |
26 | | -- [Browser Compatibility](#browser-compatibility) |
27 | | -- [FQA](#fqa) |
28 | | - - [Q1. Tainted canvases may not be exported.](#q1-tainted-canvases-may-not-be-exported) |
29 | | -- [License](#license) |
30 | | -- [EasyQRCodeJS-Premium:](#easyqrcodejs-premium) |
31 | | -- [End](#end) |
| 10 | +- [EasyQRCodeJS](#easyqrcodejs) |
| 11 | + - [Table of contents](#table-of-contents) |
| 12 | + - [Choose what you need](#choose-what-you-need) |
| 13 | + - [Feature](#feature) |
| 14 | + - [Try It!](#try-it) |
| 15 | + - [Demo preview](#demo-preview) |
| 16 | + - [QR Code Structure](#qr-code-structure) |
| 17 | + - [Installation](#installation) |
| 18 | + - [Load](#load) |
| 19 | + - [Basic Usages](#basic-usages) |
| 20 | + - [QRCode API](#qrcode-api) |
| 21 | + - [Object](#object) |
| 22 | + - [Options](#options) |
| 23 | + - [Method](#method) |
| 24 | + - [Angular Support](#angular-support) |
| 25 | + - [Vue.js Support](#vuejs-support) |
| 26 | + - [React Support](#react-support) |
| 27 | + - [Next.js Support](#nextjs-support) |
| 28 | + - [Svelte Support](#svelte-support) |
| 29 | + - [FQA](#fqa) |
| 30 | + - [Q1. Tainted canvases may not be exported.](#q1-tainted-canvases-may-not-be-exported) |
| 31 | + - [Browser Compatibility](#browser-compatibility) |
| 32 | + - [License](#license) |
| 33 | + - [EasyQRCodeJS-Premium](#easyqrcodejs-premium) |
| 34 | + - [End](#end) |
32 | 35 |
|
33 | 36 |
|
34 | 37 | ## Choose what you need |
@@ -66,7 +69,7 @@ EasyQRCodeJS 是一个功能丰富的跨浏览器的纯 JavaScript QRCode 生成 |
66 | 69 |
|
67 | 70 | - Support AMD, CMD, CommonJS/Node.js JavaScript modules |
68 | 71 |
|
69 | | - - Angular, Vue.js, React, Next.js Support |
| 72 | + - Angular, Vue.js, React, Next.js, Svelte Support |
70 | 73 |
|
71 | 74 | - Support binary(hex) data mode |
72 | 75 |
|
@@ -96,7 +99,7 @@ EasyQRCodeJS 是一个功能丰富的跨浏览器的纯 JavaScript QRCode 生成 |
96 | 99 |
|
97 | 100 | - 支持 AMD,CMD, CommonJS/Node.js JavaScript 模块加载规范 |
98 | 101 |
|
99 | | - - Angular, Vue.js, React, NEXT.js 支持 |
| 102 | + - Angular, Vue.js, React, NEXT.js, Svelte 支持 |
100 | 103 |
|
101 | 104 | - 二进制数据模式支持 |
102 | 105 |
|
@@ -650,6 +653,84 @@ var qrcode = new QRCode(DOM_object, options_object); |
650 | 653 | ``` |
651 | 654 |
|
652 | 655 |
|
| 656 | +## Svelte Support |
| 657 | + |
| 658 | +1. Add dependency |
| 659 | + |
| 660 | + ```Shell |
| 661 | + # install with `npm` |
| 662 | + npm install --save-dev easyqrcodejs |
| 663 | + |
| 664 | + # Alternatively you may use `yarn`: |
| 665 | + yarn add easyqrcodejs --dev |
| 666 | + ``` |
| 667 | + |
| 668 | +2. Component template |
| 669 | + |
| 670 | + QR.svelte: |
| 671 | + |
| 672 | + ```HTML |
| 673 | + <script> |
| 674 | + import { onMount } from 'svelte'; |
| 675 | + import * as QRCode from 'easyqrcodejs'; |
| 676 | +
|
| 677 | + export let text; |
| 678 | + let node; |
| 679 | +
|
| 680 | + onMount(() => { |
| 681 | + const options = { |
| 682 | + text: codeValue, |
| 683 | + // ... your other options |
| 684 | + width: 100, |
| 685 | + height: 100, |
| 686 | + quietZone: 10, |
| 687 | + }; |
| 688 | + new QRCode(node, options); |
| 689 | + }); |
| 690 | + </script> |
| 691 | +
|
| 692 | + <div bind:this={node}></div> |
| 693 | +
|
| 694 | + <style> |
| 695 | + div { |
| 696 | + /* make QR-wrapper squared */ |
| 697 | + width: 100%; |
| 698 | + position: relative; |
| 699 | + padding: 50%; |
| 700 | + z-index: 1; |
| 701 | + } |
| 702 | + div :global(canvas) { |
| 703 | + /* fit QR to wrapper */ |
| 704 | + width: 100%; |
| 705 | + height: 100%; |
| 706 | + position: absolute; |
| 707 | + left: 0; |
| 708 | + top: 0; |
| 709 | + } |
| 710 | + </style> |
| 711 | + ``` |
| 712 | + |
| 713 | +3. Layout |
| 714 | + |
| 715 | + index.svelte: |
| 716 | +
|
| 717 | + ```HTML |
| 718 | + <script> |
| 719 | + import QR from './QR.svelte'; |
| 720 | + </script> |
| 721 | +
|
| 722 | + <div class="qr-container"> |
| 723 | + <QR text="Your awesome text here..." /> |
| 724 | + </div> |
| 725 | +
|
| 726 | + <style> |
| 727 | + .qr-container { |
| 728 | + /* your styles for container here */ |
| 729 | + } |
| 730 | + </style> |
| 731 | + ``` |
| 732 | +
|
| 733 | +
|
653 | 734 | ## FQA |
654 | 735 |
|
655 | 736 | ### Q1. Tainted canvases may not be exported. |
@@ -680,7 +761,7 @@ When use canvas drawer, Canvas toDataURL function does not allow load cross doma |
680 | 761 | Use base64 image. |
681 | 762 |
|
682 | 763 |
|
683 | | - |
| 764 | +
|
684 | 765 | ## Browser Compatibility |
685 | 766 | IE6+, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC. |
686 | 767 |
|
|
0 commit comments