elementUi文件上传
代码】elementUi文件上传。
·
说明:
action:必填
auto-upload:el-upload组件自动上传,默认值为true, false为关闭自动上传
/**
* 手动上传
*/
upLoad() {
this.$refs.imageUpload.submit()
},
<el-upload
ref="imageUpload"
:action="crmFileSaveUrl"
:headers="httpHeader"
:data="{type: 'img', batchId: batchId}"
:on-preview="handleFilePreview"
:before-remove="beforeRemove"
:on-success="imgFileUploadSuccess"
:file-list="imgFileList"
:before-upload="handleBeforeUpload"
:auto-upload="autoUpload"
:disabled="isUpload"
name="file"
multiple
accept="image/*"
list-type="picture-card"
/>
handleBeforeUpload(file) {
// 限制文件上传大小
const isLt10M = file.size / 1024 / 1024 < 10
if (!isLt10M) {
this.$message.error('上传文件大小不能超过 10MB!')
return false
}
},
更多推荐
已为社区贡献1条内容
所有评论(0)