<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;
},
