2023-04-25 11:33:52 +08:00

43 lines
670 B
Vue

<template>
<img class="magic-ui-qrcode" :src="imgUrl" />
</template>
<script lang="ts" setup>
import { ref, watch } from 'vue';
import QRCode from 'qrcode';
import type { MComponent } from '@tmagic/schema';
import useApp from '../../useApp';
const props = withDefaults(
defineProps<{
config: MComponent;
model?: any;
}>(),
{
model: () => ({}),
},
);
const imgUrl = ref();
watch(
() => props.config.url,
(url = '') => {
QRCode.toDataURL(url, (e: any, url: string) => {
if (e) console.error(e);
imgUrl.value = url;
});
},
{
immediate: true,
},
);
useApp({
config: props.config,
methods: {},
});
</script>