<el-upload
accept=".jpg,.png,.jpeg"
class="editor-avatar-uploader"
:action="serverUrl"
name="file"
:headers="header"
:show-file-list="false"
list-type="picture"
:multiple="false"
:on-success="uploadSuccess"
:on-error="uploadError"
:before-upload="beforeUpload">
</el-upload>
beforeUpload(file) {
const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
const whiteList = ["jpg","png","jpeg"];
if (whiteList.indexOf(fileSuffix) === -1) {
this.message({message:"上传文件只能是 jpg,png格式", type: 'warning'});
return false;
}
},