# qrcode.vue-next

> [qrcode.react](https://github.com/zpao/qrcode.react)的vue版本实现，最开始是[ant-design-vue](https://www.antdv.com)在QRCode组件中完成迁移，此仓库将其剥离出来，不是重复造轮子，而是满足在有使用二维码场景但组件库选型不是ant-design-vue的情况下，能够使用到[qrcode.react](https://github.com/zpao/qrcode.react)这一业界优秀实现，感谢qrcode.rea

Latest version **1.0.0** (published 2025-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install qrcode.vue-next
pnpm add qrcode.vue-next
yarn add qrcode.vue-next
bun add qrcode.vue-next
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2025-09-26 |
| First published | 2023-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 91.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | UseComponents |
| Maintainers | selicens |
| Keywords | qrcode, vue, vue-qrcode, qrcode.vue, qrcode-vue-next, qrcode.vue3, vue3-qrcode, vue3-qrcode-next |

## Links

- npm: https://www.npmjs.com/package/qrcode.vue-next
- Repository: https://github.com/UseComponents/qrcode
- Homepage: https://usecomponents.github.io/qrcode/
- Issues: https://github.com/UseComponents/qrcode/issues
- npm.io page: https://npm.io/package/qrcode.vue-next

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^3.5.22

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2025-09-26
- 0.0.11 — 2025-09-17
- 0.0.10 — 2024-01-30
- 0.0.9 — 2024-01-06
- 0.0.8 — 2024-01-06
- 0.0.7 — 2023-12-28
- 0.0.6 — 2023-12-16
- 0.0.5 — 2023-12-14
- 0.0.4 — 2023-12-14
- 0.0.3 — 2023-12-14
- 0.0.2 — 2023-12-13

## README

# qrcode.vue-next

[qrcode.react](https://github.com/zpao/qrcode.react)的vue版本实现，最开始是[ant-design-vue](https://www.antdv.com)在QRCode组件中完成迁移，此仓库将其剥离出来，不是重复造轮子，而是满足在有使用二维码场景但组件库选型不是ant-design-vue的情况下，能够使用到[qrcode.react](https://github.com/zpao/qrcode.react)这一业界优秀实现，感谢qrcode.react与ant-design-vue为开源做出的贡献

## 在线预览

[qrcode.vue-next](https://usecomponents.github.io/qrcode/)

## 安装

```sh
npm install qrcode.vue-next
```

## 使用

`qrcode.vue-next`导出三个组件，支持以SVG或Canvas形式呈现。通常建议使用SVG，因为它更灵活，但Canvas可能更可取。

### `Canvas`

```js
import QRCode fom 'qrcode.vue-next';

<template>
  <QRCode value="https://vuejs.org/" />
</template>
```

### `SVG`

```js
import QRCode fom 'qrcode.vue-next';

<template>
  <QRCode value="https://vuejs.org/" type="svg" />
</template>
```

### `自定义`

如果不满足封装的QRCode提供的样式与功能，可以直接导出`QRCodeCanvas`或`QRCodeSVG`来使用，并传递所需props，然后就可以自由创造了。

```js
import QRCode, { QRCodeCanvas, QRCodeSVG } from 'qrcode.vue-next';

const qrcodeProps = {
  value: 'https://vuejs.org',
  size: 134,
  level: 'M',
  bgColor: 'transparent',
  fgColor: 'rgba(0, 0, 0, 0.88)',
  imageSettings: {
    src: 'https://vuejs.org/images/logo.png',
    x: undefined,
    y: undefined,
    height: 40,
    width: 40,
    excavate: true
  }
}

<template>
  <QRCodeCanvas v-bind="qrcodeProps" />
  <br />
  <QRCodeSVG v-bind="qrcodeProps" />
</template>

```

## 封装后的API，基于antd

| 参数 | 类型 | 默认值 | 说明 |
| ---- | ---- | ------------- | ---- |
| `bgColor` | `string` | `'transparent'` | 二维码背景颜色 |
| `bordered` | `boolean` | `true` | 是否显示边框 |
| `color` | `string` | `'#000000'` | 二维码颜色 |
| `errorLevel` | `'L'` \| `'M'` \| `'Q'` \| `'H'` | `'L'` | 二维码纠错等级 |
| `icon` | `string` | - | 二维码中的图片地址 |
| `iconSize` | `number` | `40` | 二维码中图片的大小 |
| `iconSettings` | `object` | `{x: undefined, y: undefined, excavate: true}` | 二维码中图片的设置 |
| `size` | `number` | `160` | 二维码渲染大小 |
| `status` | `'active'` \| `'expired'` \| `'loading'` \| `'scanned'` | `'active'` | 二维码状态 |
| `type` | `'canvas'` \| `'svg'` | `'canvas'` | 渲染类型 |
| `value` | `string` | - | 扫描后的地址 |

### 事件

| 事件名 | 说明 | 回调参数 |
| ---- | ---- | ---- |
| `change` | 二维码绘制完成时触发 | () => void |
| `refresh` | 点击刷新按钮时触发 | () => void |

## 原本的API

| prop            | type                         | default value | note |
| --------------- | ---------------------------- | ------------- | ---- |
| `value`         | `string`                     |               |      |
| `size`          | `number`                     | `128`         |      |
| `bgColor`       | `string`                     | `"#FFFFFF"`   | CSS color |
| `fgColor`       | `string`                     | `"#000000"`   | CSS color |
| `level`         | `string` (`'L' 'M' 'Q' 'H'`) | `'L'`         |           |
| `minVersion`    | `number` (1-40)              | `1`           | QR Code versions are 1-40. The optimal (lowest) version is determined for the `value` provided, using this minimum as the lower bound. |
| `includeMargin` | `boolean`                    | `false`       | **DEPRECATED**. This is being removed in favor of `marginSize` |
| `marginSize`    | `number`                     | `0`           | Specifies the number of _modules_ to use for margin around the symbol. The QR Code specification requires `4`, however you may use other values. Values will be turned to integers with `Math.floor`. Overrides `includeMargin` default value when specified |
| `imageSettings` | `object`                     |               | See below |

### `imageSettings`

| field      | type      | default value     | note |
| ---------- | --------- | ----------------- | ---- |
| `src`      | `string`  |                   |      |
| `x`        | `number`  | none              | Will attempt to center if not specified |
| `y`        | `number`  | none              | Will attempt to center if not specified |
| `height`   | `number`  | 10% of `size`     |      |
| `width`    | `number`  | 10% of `size`     |      |
| `excavate` | `boolean` | `false`           |      |
| `opacity`  | `number`  | 1                 |      |

## 自定义样式

`qrcode.vue-next`将通过任何附加的道具传递到底层DOM节点（`＜svg＞`或`＜canvas＞`）。这允许使用内联“style”或自定义“class”来自定义渲染。一个常见的用途是支持响应式布局。

**注意:** 为了在高密度显示器上渲染`＜canvas＞`中的二维码，我们缩放画布元素以包含适当数量的像素，然后使用内联样式进行缩小。我们将合并任何其他样式，自定义的`height`和`width`将覆盖我们原本的值。这允许缩放到百分比_but_如果缩放超过`size`，您将遇到模糊的图像。建议在渲染到`＜canvas＞`时传递适当的大小.

<img src="src/assets/qrcode.png" height="160" width="160">

## 编码模式

`qrcode.vue-next`仅支持在单个段中对文本进行编码。所使用的编码库进行最少的检测，以确定所编码的文本是否可以遵循数字或字母数字模式的优化路径，从而允许对更多数据进行编码。否则，它将按照字节模式进行编码。此模式包括支持多字节Unicode字符（如汉字），但不支持优化的汉字编码模式。.

---
_Source: https://npm.io/package/qrcode.vue-next · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
