update:更新

This commit is contained in:
2021-06-08 10:17:48 +08:00
parent 3cbb69078b
commit 0da9f368b8

View File

@@ -45,20 +45,24 @@ export default {
const updateValue = value => { const updateValue = value => {
context.emit("update:fileId", value); // 传递的方法 context.emit("update:fileId", value); // 传递的方法
}; };
const beforeUpload = file => { const beforeUpload = (file, fileList) => {
console.log(file); console.log(file, fileList);
const isValid = const isValid =
props.isPdf === true props.isPdf === true
? file.type === "application/pdf" ? file.type === "application/pdf"
: file.type === "image/jpeg" || file.type === "image/png"; : file.type === "image/jpeg" || file.type === "image/png";
if (!isValid) { if (!isValid) {
message.error("只能上传受支持格式的文件"); message.error("只能上传受支持格式的文件");
fileList.pop();
return false;
} }
const isLt2M = file.size / 1024 / 1024 < 2; const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) { if (!isLt2M) {
message.error("文件大小超过2MB!"); message.error("文件大小超过2MB!");
fileList.pop();
return false;
} }
return isValid && isLt2M; return true;
}; };
const handleChange = info => { const handleChange = info => {
console.log(info.file.status, info.file, info.fileList); console.log(info.file.status, info.file, info.fileList);