Skip to content

⬅️ Back to Table of Contents

📄 useQRCode

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 6
⚡ Async/Await Patterns 1
🟢 Vue Composition API 1

📚 Table of Contents

🛠️ File Location:

📂 packages/integrations/useQRCode/index.ts

📦 Imports

Name Source
MaybeRefOrGetter vue
isClient @vueuse/shared
toRef @vueuse/shared
QRCode qrcode
shallowRef vue
watch vue

Async/Await Patterns

Type Function Await Expressions Promise Chains
await-expression useQRCode QRCode.toDataURL(value, options) none

Vue Composition API

Name Type Reactive Variables Composables
watch watch none none

Functions

useQRCode(text: MaybeRefOrGetter<string>, options: QRCode.QRCodeToDataURLOptions): any

Wrapper for qrcode.

Parameters:

  • text any: No description
  • options any: No description

See: https://vueuse.org/useQRCode

Raw JSDoc
/**
 * Wrapper for qrcode.
 *
 * @see https://vueuse.org/useQRCode
 * @param text
 * @param options
 */

Calls:

  • toRef (from @vueuse/shared)
  • shallowRef (from vue)
  • watch (from vue)
  • QRCode.toDataURL
Code
export function useQRCode(
  text: MaybeRefOrGetter<string>,
  options?: QRCode.QRCodeToDataURLOptions,
) {
  const src = toRef(text)
  const result = shallowRef('')

  watch(
    src,
    async (value) => {
      if (src.value && isClient)
        result.value = await QRCode.toDataURL(value, options)
    },
    { immediate: true },
  )

  return result
}

Generated by Syntax Scribe