Upload
基础用法
<template>
<ai-form ref="formEl" :model="formInfo" :formConfig="formConfig"></ai-form>
</template>
<script setup>
import { ref, reactive, computed } from 'vue'
const formInfo = reactive({
image: ''
})
const formConfig = computed(() => {
return [
{
key: 'image',
label: '头像',
type: 'upload',
model: 'image',
prop: 'image',
isImage: true,
fileTypes: ['jpg', 'png', 'gif'],
width: 24,
required: true
}
]
})
</script>Props
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| type | upload | string | - |
| key | 配置列表唯一标识 | string | - |
| label | 标签文本 | string | - |
| model | 属性名,它可以是属性的路径(如a.b.0)也可以是一个方法,返回属性路径,该属性是必填的 | string/Function | - |
| prop | 一般和属性名保持一致,在使用了validate、resetFields的方法时,该属性是必填的 | string/Function | - |
| width | 宽度(1-24) | number | 12 |
| noneLabel | 是否隐藏标签 | boolean | false |
| placeholder | 输入框占位文本 | string | - |
| disabled | 是否禁用 | boolean/Function | false |
| size | 输入框尺寸 | string | - |
| required | 是否必填 | boolean | false |
| validator | 自定义校验方法 | Function | - |
| fileTypes | 支持上传的文件类型 | array | [] |
| fileSize | 支持上传的文件最大尺寸 | number | - |
| autoUpload | 是否自动上传文件 | boolean | true |
| beforeUpload | 上传文件之前的钩子 | Function | - |
| afterUpload | 上传文件之后的钩子 | Function | - |
| headers | 设置上传的请求头部 | object | - |
| isImage | 是否展示图片回显 | boolean | false |
| multiple | 是否支持多选文件 | boolean | false |
| readOnly | 是否只读 | boolean | false |
| limit | 允许上传文件的最大数量 | number | - |
| showFileList | 是否显示已上传文件列表 | boolean | true |
| showErrorTooltip | 是否展示错误提示 | boolean | true |
| changeFun | 当绑定值变化时触发的回调函数 | Function | - |
| showFun | 是否展示的判断函数,返回一个boolean值 | Function | - |