2.0.0
Skip to content

FileCard 文件卡片 ​

用卡片的形式展示文件。

何时使用 ​

  • 用于在对话或输入时展示文件。

代码演示 ​

基础用法 ​

excel-has-long-long-long-name.xlsx
1 KB
word-file.docx
1 KB
pdf-file.pdf
1 KB
ppt-file.pptx
1 KB
zip-file.zip
1 KB
txt-file.txt
1 KB
markdown-file.md
1 KB
java-file.java
1 KB
javascript-file.js
1 KB
python-file.py
1 KB
excel-file.xlsx
1 KB
基础用法

不同类型文件会自动匹配对应图标和颜色。

卡片大小 ​

pdf-file.pdf
1 KB
pdf-file.pdf
1 KB
卡片大小

通过 size 属性设置卡片大小。

图片文件 ​

image-file.png
Preview
image-file.png
Preview
image-file.png
1 KB
图片文件

图片类型文件会自动展示图片预览。可通过 type="file" 强制展示为文件卡片。

图片加载 ​

0%
Image placeholder
0%
Image placeholder
图片加载

图片加载时显示加载动画。

音视频类型 ​

audio-file.mp3
1 KB
video-file.mp4
1 KB
音视频类型

音频和视频类型文件支持内联播放,也可通过 type="file" 以文件卡片形式展示。

使用遮罩 ​

txt-file.txt
1 KB
使用遮罩

通过 mask 属性添加遮罩内容。

自定义图标 ​

txt-file.txt
1 KB
android-file.apk
1 KB
自定义图标

通过 icon 属性自定义图标,支持传入预设图标名称或自定义 VNode。

文件列表 ​

excel-file.xlsx
1 KB
word-file.docx
1 KB
pdf-file.pdf
1 KB
ppt-file.pptx
1 KB
zip-file.zip
1 KB
txt-file.txt
1 KB
excel-file.xlsx
1 KB
word-file.docx
1 KB
pdf-file.pdf
1 KB
ppt-file.pptx
1 KB
zip-file.zip
1 KB
txt-file.txt
1 KB
image-file.png
Preview
image-file.png
Preview
image-file.png
Preview
image-file.png
Preview
image-file.png
Preview
image-file.png
Preview
image-file.png
Preview
image-file.png
Preview
image-file.png
Preview
文件列表

使用 FileCard.List 展示文件列表,支持删除和图片预览。

超出样式 ​

image-file-0.png
Preview
image-file-1.png
Preview
image-file-2.png
Preview
image-file-3.png
Preview
image-file-4.png
Preview
image-file-5.png
Preview
image-file-6.png
Preview
image-file-7.png
Preview
image-file-8.png
Preview
image-file-9.png
Preview
image-file-10.png
Preview
excel-file.xlsx
1 KB
word-file.docx
1 KB
pdf-file.pdf
1 KB
ppt-file.pptx
1 KB
zip-file.zip
1 KB
txt-file.txt
1 KB
超出样式

通过 overflow 属性控制列表超出时的展示方式。

API ​

FileCardProps ​

属性说明类型默认值版本
name文件名称string--
byte文件大小(字节)number--
size卡片大小'small' | 'default''default'-
description文件描述VNode | string--
loading是否处于加载状态booleanfalse-
type文件类型'file' | 'image' | 'audio' | 'video' | string--
src图片或文件地址string--
mask遮罩内容VNode | string--
icon自定义图标VNode | PresetIcons--
imageProps图片属性,同 ant-design-vue Image 属性ImageProps--
videoProps视频属性配置Record<string, any>--
audioProps音频属性配置Record<string, any>--
spinProps加载中属性SpinProps & { showText?: boolean; icon?: VNode }--
onClick点击事件回调() => void--

PresetIcons ​

预设图标类型,支持以下值:

typescript
type PresetIcons =
  | 'default'    // 默认文件图标
  | 'excel'      // Excel 文件图标
  | 'image'      // 图片文件图标
  | 'markdown'   // Markdown 文件图标
  | 'pdf'        // PDF 文件图标
  | 'ppt'        // PowerPoint 文件图标
  | 'word'       // Word 文件图标
  | 'zip'        // 压缩文件图标
  | 'video'      // 视频文件图标
  | 'audio'      // 音频文件图标
  | 'java'       // Java 文件图标
  | 'javascript' // JavaScript 文件图标
  | 'python';    // Python 文件图标

FileCard.List ​

文件列表组件,用于展示多个文件卡片。

属性说明类型默认值版本
items文件列表数据。每一项是 FileCardProps,并可用 key 作为稳定标识;缺省时回退为 name-index(FileCardProps & { key?: string | number })[]--
size卡片大小'small' | 'default''default'-
removable是否可删除boolean | ((item: FileCardProps) => boolean)false-
onRemove删除事件回调(item: FileCardProps) => void--
extension扩展内容VNode--
overflow超出展示方式'scrollX' | 'scrollY' | 'wrap''wrap'-

Semantic DOM ​

pdf-file.pdf
1 KB
  • root
    根节点
  • file
    文件
  • icon
    图标
  • name
    名称
  • description
    描述
excel-file.xlsx
1 KB
excel-file.xlsx
1 KB
excel-file.xlsx
1 KB
  • root
    根节点
  • card
    卡片
  • file
    文件
  • icon
    图标
  • name
    名称
  • description
    描述

主题变量(Design Token) ​

组件暂无自定义 Component Token,可通过全局 Design Token 定制。