initial
This commit is contained in:
29
layers/ui/components/qr-code/index.vue
Normal file
29
layers/ui/components/qr-code/index.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<canvas ref="canvasEl" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import QRCode from 'qrcode'
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
size: {
|
||||
type: Number,
|
||||
default: 128,
|
||||
},
|
||||
})
|
||||
|
||||
const canvasEl = ref()
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await QRCode.toCanvas(canvasEl.value, props.value, { margin: 1, width: props.size })
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user