Skip to content

Commit 56af7fd

Browse files
committed
fix: errorCorrectLevel error.
1 parent 4eb182e commit 56af7fd

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

example/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
<div class="col-sm-10">
6363
<select v-model="level" class="form-control">
6464
<option value="L">L</option>
65-
<option value="Q">Q</option>
6665
<option value="M">M</option>
66+
<option value="Q">Q</option>
6767
<option value="H">H</option>
6868
</select>
6969
</div>
@@ -120,7 +120,7 @@ import QrcodeVue from '../src'
120120
121121
const value = ref('https://example.com')
122122
const size = ref(100)
123-
const level = ref<'L' | 'Q' | 'M' | 'H'>('L')
123+
const level = ref<'L' | 'M' | 'Q' | 'H'>('L')
124124
const background = ref('#ffffff')
125125
const foreground = ref('#000000')
126126
const renderAs = ref<'canvas' | 'svg'>('svg')

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qrcode.vue",
3-
"version": "3.3.2",
3+
"version": "3.3.3",
44
"description": "A Vue.js component to generate QRCode.",
55
"main": "dist/qrcode.vue.cjs.js",
66
"module": "dist/qrcode.vue.esm.js",

src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineComponent, h, onMounted, onUpdated, PropType, ref } from 'vue'
2-
import QR, { ErrorCorrectLevel } from 'qr.js'
2+
import QR from 'qr.js/lib/QRCode.js'
3+
import ErrorCorrectLevel from 'qr.js/lib/ErrorCorrectLevel.js'
34

45
type Modules = boolean[][]
56
type Level = 'L' | 'M' | 'Q' | 'H'
@@ -20,7 +21,11 @@ function QRCode(data: string, level: Level): { modules: Modules } {
2021
const errorCorrectLevel = ErrorCorrectLevel[level]
2122

2223
// We'll use type===-1 to force QRCode to automatically pick the best type
23-
return QR(toUTF8String(data), { typeNumber: -1, errorCorrectLevel })
24+
const qrcode = new QR(-1, errorCorrectLevel)
25+
qrcode.addData(toUTF8String(data))
26+
qrcode.make()
27+
28+
return qrcode
2429
}
2530

2631
function validErrorCorrectLevel(level: string): boolean {

typings/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
declare module 'qr.js'
1+
declare module 'qr.js/lib/QRCode.js'
2+
declare module 'qr.js/lib/ErrorCorrectLevel.js'
23

34
// shims-vue.d.ts
45
declare module '*.vue' {

0 commit comments

Comments
 (0)