|
@@ -192,10 +192,19 @@ const header = props => {
|
192
|
192
|
});
|
193
|
193
|
}
|
194
|
194
|
|
195
|
|
- const beforeUpload = file =>{
|
|
195
|
+ function beforeUpload(file) {
|
196
|
196
|
console.log("开始上传")
|
197
|
197
|
console.log(file)
|
198
|
|
- }
|
|
198
|
+ const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
|
199
|
+ if (!isJpgOrPng) {
|
|
200
|
+ message.error('请上传jpg格式的图片');
|
|
201
|
+ }
|
|
202
|
+ const isLt2M = file.size / 1024 / 1024 < 2;
|
|
203
|
+ if (!isLt2M) {
|
|
204
|
+ message.error('Image must smaller than 2MB!');
|
|
205
|
+ }
|
|
206
|
+ return isJpgOrPng && isLt2M;
|
|
207
|
+ }
|
199
|
208
|
|
200
|
209
|
return (
|
201
|
210
|
<>
|