Warp/node_modules/@vueuse/integrations/useQRCode.mjs

20 lines
423 B
JavaScript
Raw Normal View History

2024-01-05 12:14:38 +00:00
import { toRef, isClient } from '@vueuse/shared';
import { ref, watch } from 'vue-demi';
import QRCode from 'qrcode';
function useQRCode(text, options) {
const src = toRef(text);
const result = ref("");
watch(
src,
async (value) => {
if (src.value && isClient)
result.value = await QRCode.toDataURL(value, options);
},
{ immediate: true }
);
return result;
}
export { useQRCode };