Skip to content

imageUpload 图片上传

基础用法

vue
<script setup lang="ts">
import type { BasicForm } from '@/types/form'

const formConfig = reactive<BasicForm>({
  formItems: [
    {
      label: '图片',
      value: '',
      name: 'name',
      type: 'image-upload',
    },
  ],
})
</script>

全局上传配置

TIP

代码位置

src/config/uploadConfig.ts

属性

ts
interface Props {
  modelValue: string
  width?: string
  height?: string
  iconSize?: number
  fileSize?: number
  autoUpload?: boolean
  disabled?: boolean
  multiple?: boolean
  drag?: boolean
  limit?: number
  progressProps?: ProgressProps
  uploadFunction?: (file: any, onUploadProgress: any) => Promise<any>
  transformData?: (data: any) => Array<UploadItem>
}
参数说明类型默认值可选值
modelValue图片路径(如果是字符串需要用英文逗号隔开)String
width上传框宽度String128px
height上传框高度String128px
iconSize上传框内图标大小Number、String28px
fileSize允许上传文件的大小(单位兆)Number、String10
autoUpload自动上传Booleantrue
disabled禁用Booleanfalse
multiple多选Booleanfalse
drag是否启用拖拽上传Booleanfalse
limit允许上传文件的最大数量Number1
progressProps进度条配置ProgressProps
uploadFunction自定义上传方法Function
transformData自定义数据转换Function

插槽

插槽名说明
tip提示说明文字
icon上传框内图标

Exposes

名称说明参数
checkUpload检查图片是否全部上传完毕
submit手动上传