Skip to content

Commit 8e42a8a

Browse files
committed
fix: forced type conversion.
github issue #85
1 parent c0e7227 commit 8e42a8a

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

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.5.0",
3+
"version": "3.5.1",
44
"description": "A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3",
55
"type": "module",
66
"main": "./dist/qrcode.vue.cjs.js",

src/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ export const QrcodeSvg = defineComponent({
187187
let imageProps: { x: number, y: number, width: number, height: number }
188188

189189
const generate = () => {
190-
const { value, level, margin } = props
190+
const { value, level: _level, margin: _margin } = props
191+
const margin = _margin >>> 0
192+
const level = validErrorCorrectLevel(_level) ? _level : defaultErrorCorrectLevel
191193

192194
let cells = QR.QrCode.encodeText(value, ErrorCorrectLevelMap[level]).getModules()
193195
numCells.value = cells.length + margin * 2
@@ -253,7 +255,9 @@ export const QrcodeCanvas = defineComponent({
253255
const imageRef = ref<HTMLImageElement | null>(null)
254256

255257
const generate = () => {
256-
const { value, level, size, margin, background, foreground } = props
258+
const { value, level: _level, size, margin: _margin, background, foreground } = props
259+
const margin = _margin >>> 0
260+
const level = validErrorCorrectLevel(_level) ? _level : defaultErrorCorrectLevel
257261

258262
const canvas = canvasEl.value
259263

@@ -355,16 +359,13 @@ const QrcodeVue = defineComponent({
355359
const {
356360
renderAs,
357361
value,
358-
size: _size,
359-
margin: _margin,
360-
level: _level,
362+
size,
363+
margin,
364+
level,
361365
background,
362366
foreground,
363367
imageSettings,
364368
} = this.$props
365-
const size = _size >>> 0
366-
const margin = _margin >>> 0
367-
const level = validErrorCorrectLevel(_level) ? _level : defaultErrorCorrectLevel
368369

369370
return h(
370371
renderAs === 'svg' ? QrcodeSvg : QrcodeCanvas,

0 commit comments

Comments
 (0)