Upload 上传

通过点击或者拖拽上传文件

点击上传

覆盖前一个文件

用户头像上传

before-upload 钩子中限制用户上传文件的格式和大小。

照片墙

使用 list-type 属性来设定文件列表的样式。

自定义文件缩略图

使用 scoped-slot 属性来改变默认的缩略图模板样式。

带缩略图的文件列表

文件列表控制

通过 on-change 钩子函数来对列表进行控制

拖拽上传

你可以将文件拖拽到特定区域以进行上传。

手动上传

属性

属性描述类型可选值默认值
action必选参数,上传的地址string
headers设置上传的请求头部object
method设置上传请求方法stringpost/put/patchPOST
multiple是否支持多选文件boolean
data上传时附带的额外参数object
name上传的文件字段名stringfile
with-credentials支持发送 cookie 凭证信息booleanfalse
show-file-list是否显示已上传文件列表booleantrue
drag是否启用拖拽上传booleanfalse
accept接受上传的 文件类型(thumbnail-mode 模式下此参数无效)string
on-preview点击文件列表中已上传的文件时的钩子function(file)
on-remove文件列表移除文件时的钩子function(file, fileList)
on-success文件上传成功时的钩子function(response, file, fileList)
on-error文件上传失败时的钩子function(err, file, fileList)
on-progress文件上传时的钩子function(event, file, fileList)
on-change文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用function(file, fileList)
before-upload上传文件之前的钩子,参数为上传的文件。 若返回 false 或者返回 Promise 且被 reject,则终止上传。function(file)
before-remove删除文件之前的钩子,参数为上传的文件和文件列表。 若返回 false 或者返回 Promise 且被 reject,则终止删除。function(file, fileList)
file-listdefault uploaded files, e.g. [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]array[]
list-typetype of fileListstringtext/picture/picture-cardtext
auto-uploadwhether to auto upload filebooleantrue
http-requestoverride default xhr behavior, allowing you to implement your own upload-file's requestfunction
disabledwhether to disable uploadbooleanfalse
limitmaximum number of uploads allowednumber
on-exceedhook function when limit is exceededfunction(files, fileList)-

插槽

名称描述参数
自定义默认内容-
trigger触发文件选择框的内容-
tip提示说明文字-
file缩略图模板的内容file ( #file = { file } )

方法

方法名描述参数默认值
clearFiles清空已上传的文件列表(该方法不支持在 before-upload 中调用)UploadStatus[](UploadStatus = 'ready' \'uploading' | 'success' | 'fail')
abort取消上传请求( file: fileList 中的 file 对象 )-
submit手动上传文件列表-
handleStart手动选择文件(file:files 中的对象)-
handleRemove手动移除文件( file: fileList 中的 file 对象 )-