<el-upload
v-loading="uploadLoading"
ref="replyUpload"
:before-upload="beforeUpload"
:http-request="uploadFile"
:data="{ tp: '2' }"
class="upload-demo"
action="api_ws/api/Contract/AttachmentUpload"
align="center"
style="float:left"
>
<el-button size="small" type="primary">点击上传</el-button>
<label slot="tip" class="el-upload__tip">
上传文件不能超过5个,上传文件大小不超过15MB
</label>
<!-- <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>-->
</el-upload>
// 上传前的校验
beforeUpload(file) {
this.uploadLoading = true;
// 校验文件大小
var result = file.size / 1024 / 1024 < 15 ? "1" : "0";
if (result === "0") {
this.$message({
message: "上传文件大小不能超过15MB!",
type: "error"
});
this.uploadLoading = false;
return false;
}
return true;
},