跳转到内容

QRCode 二维码

何时使用

当需要将文本转换成为二维码时使用。

代码演示

基本使用

loading

带 Icon 的例子

loading

不同的状态

loading

自定义状态渲染器

loading

自定义渲染类型

loading

自定义尺寸

loading

自定义颜色

loading

下载二维码

loading

纠错比例

loading

高级用法

loading

API

antd@5.1.0 版本开始提供该组件。

参数说明类型默认值版本
value扫描后的文本string-
type渲染类型canvas | svg canvas5.6.0
icon二维码中图片的地址(目前只支持图片地址)string-
size二维码大小number160
iconSize二维码中图片的大小number | { width: number; height: number }405.19.0
color二维码颜色string#000
bgColor二维码背景颜色stringtransparent5.5.0
bordered是否有边框booleantrue
errorLevel二维码纠错等级'L' | 'M' | 'Q' | 'H' M
status二维码状态active | expired | loading | scannedactivescanned: 5.13.0
statusRender自定义状态渲染器(info: [StatusRenderInfo]) => VNode-5.20.0
onRefresh点击"点击刷新"的回调() => void-

StatusRenderInfo

typescript
type StatusRenderInfo = {
  status: QRStatus;
  locale: Locale['QRCode'];
  onRefresh?: () => void;
};

基于 MIT 许可发布