主题
使用二维码
¥useQRCode
qrcode 的封装。
¥Wrapper for qrcode.
示例
Available in the @vueuse/integrations add-on.安装
¥Install
bash
npm i qrcode@^1用法
¥Usage
ts
import { useQRCode } from '@vueuse/integrations/useQRCode'
// `qrcode` will be a ref of data URL
const qrcode = useQRCode('text-to-encode')或者传递一个 ref 给它,返回的数据 URL ref 将随着源 ref 的变化而变化。
¥or passing a ref to it, the returned data URL ref will change along with the source ref's changes.
ts
import { useQRCode } from '@vueuse/integrations/useQRCode'
import { shallowRef } from 'vue'
const text = shallowRef('text-to-encode')
const qrcode = useQRCode(text)html
<input v-model="text" type="text" />
<img :src="qrcode" alt="QR Code" />