一个支持自定义属性的 Vue 3 二维码组件
| Files | Last commit | Last update |
|---|---|---|
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago | ||
| 10 months ago |
Vue3 Qrcode Component
A customizable QR Code component for Vue 3 applications.
Features
- Fully customizable (size, colors, icon)
- TypeScript support
- Built with Vite
- Easy to use
- Vue 3 Composition API
Installation
npm install vue3-qrcode-component
or
yarn add vue3-qrcode-component
or
pnpm add vue3-qrcode-component
Usage
Global Registration
import { createApp } from 'vue'
import App from './App.vue'
import Qrcode from 'vue3-qrcode-component'
const app = createApp(App)
app.use(Qrcode)
app.mount('#app')
<template>
<Qrcode url="https://github.com" />
</template>
Local Registration
<template>
<Qrcode
url="https://vuejs.org"
:wid="150"
:hei="150"
colorDark="#42b983"
colorLight="#ffffff"
iconurl="https://cn.vuejs.org/images/logo.png"
:imgwid="30"
:imghei="30"
/>
</template>
<script setup lang="ts">
import { Qrcode } from 'vue3-qrcode-component'
</script>
Props
| Property | Description | Type | Default |
|---|---|---|---|
url |
Values of Qrcode (二维码输入的内容) | String | 'www.baidu.com' |
iconurl |
Image of Qrcode (二维码中间小图片地址) | String | undefined |
wid |
Qrcode width (二维码宽度) | Number | 70 |
hei |
Qrcode height (二维码高度) | Number | 70 |
colorDark |
Qrcode color (二维码颜色) | String | '#000000' |
colorLight |
Qrcode background (二维码背景色) | String | '#ffffff' |
imgwid |
Qrcode image width (二维码中间小图片宽度) | Number | 30 |
imghei |
Qrcode image height (二维码中间小图片高度) | Number | 30 |
correctLevel |
Error correction level (0-3: L/M/Q/H) | Number | 3 |
margin |
Qrcode margin in modules (二维码留白间距) | Number | 0 |
Note:
iconurlis optional. Without it, the QR code will be displayed without a center icon.margincontrols the white space around the QR code. Set to0for no margin (full coverage), or use values like1-4for better scan recognition.
Examples
Basic QR Code (Without Icon)
<Qrcode url="https://github.com" />
Custom Size and Colors
<Qrcode
url="https://vuejs.org"
:wid="200"
:hei="200"
colorDark="#4CAF50"
colorLight="#E8F5E9"
/>
With Center Icon
<Qrcode
url="https://cn.vuejs.org"
iconurl="https://cn.vuejs.org/images/logo.png"
:wid="200"
:hei="200"
:imgwid="40"
:imghei="40"
/>
Custom Margin (White Space)
<!-- No margin - full coverage (完全铺满) -->
<Qrcode
url="https://github.com"
:wid="200"
:hei="200"
:margin="0"
/>
<!-- Minimal margin (最小留白) -->
<Qrcode
url="https://github.com"
:wid="200"
:hei="200"
:margin="1"
/>
<!-- Standard margin - recommended for better scan recognition (标准留白,推荐) -->
<Qrcode
url="https://github.com"
:wid="200"
:hei="200"
:margin="4"
/>
Development
# Install dependencies
npm install
# Start development server
npm run dev
# Build library
npm run build
# Preview build
npm run preview
License
MIT
Author
全栈若城
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.