<WebUploader ref="$WU"
icon="el-icon-upload"
type="primary"
reset-by-click
list-url=""
@uploadSuccess="upload_success"
:limit="1"
:show-file-list="false"
del-url=""
:files.sync="model.files"
>{{ $t('文件上传') }}
</WebUploader>
data(){
return{
model:{
files:[]
}
}
},
methods: {
upload_success(ids) {
this.model.files = ids }
}
属性:
allowed-folder {boolean} 为true开启文件夹上传功能
folder-id {number} 创建文件夹时的上级文件夹id 默认为null,在根目录创建
create-folder-url {string} 创建文件夹的url 默认值为/plan/drawer/data/folder/create
link-folder-file-url {string} 文件夹关联文件的url 默认值为/plan/drawer/data/upload
uploadurl {string} 文件上传的url 默认为 basedata/file_store/upload
mergeurl {string} 文件合并的url 默认为 basedata/file_store/merge
del-url {string} 文件删除的url 默认为 /plan/dynamic_project/file/del
show-upload-button {boolean} 是否展示文件上传按钮 默认为true
parameter {object} 业务参数 文件上传时携带的自定义参数
files.sync :动态绑定上传成功的文件id数组
auto-upload {boolean}:文件选择完毕之后,自动上传。默认为true
icon:上传按钮图标,同el-button用法一样
type:按钮类型,同el-button用法一样
reset-by-click {boolean}:点击上传按钮时立即清空文件上传列表,默认为true
list-url {string} :指定已上传文件列表的接口,配合this.WU.get_file_list_by_id(id)使用,获取已上传文件列表(表格)
limit {number}:限制文件最大上传个数,不指定则无限制,单个文件上传时可指定为 :limit="1"
show-file-list {boolean}:指定为true时,显示已上传文件列表,false则隐藏,默认为true
show-upload-button{boolean}:指定为true时,显示“点击上传”按钮,false则隐藏,默认为true,
del-url {string}:指定已上传文件删除的接口地址
事件
uploadSuccess {function(ids=>{})}:传入一个回调函数(upload_success),一个或者一批文件上传成功时执行该回调函数,返回由成功上传文件返回的数组(ids),
uploadSuccessChange {function(ids=>{})}:传入一个回调函数(upload_success_change),一个或者一批文件上传时,每上传成功一个文件,触发一一次回调,返回由成功上传文件返回的数组(ids)
方法:
reset:清空文件上传列表、已上传文件列表、:files.sync绑定的变量值
reset_upload_file_list:清空已上传文件列表
get_file_list_by_id(id):根据id获取文件已上传列表信息