@@ -29,10 +29,10 @@ The return value of function `beforeUpload` can be a Promise to check asynchrono
29
29
</a-upload >
30
30
</template >
31
31
<script >
32
- function getBase64 (img , callback ) {
33
- const reader = new FileReader ();
34
- reader .addEventListener (' load' , () => callback (reader .result ));
35
- reader .readAsDataURL (img);
32
+ function getBase64 (img , callback ) {
33
+ const reader = new FileReader ()
34
+ reader .addEventListener (' load' , () => callback (reader .result ))
35
+ reader .readAsDataURL (img)
36
36
}
37
37
export default {
38
38
data () {
@@ -42,38 +42,47 @@ export default {
42
42
}
43
43
},
44
44
methods: {
45
- handleChange (info ) {
45
+ handleChange (info ) {
46
46
if (info .file .status === ' uploading' ) {
47
47
this .loading = true
48
- return ;
48
+ return
49
49
}
50
50
if (info .file .status === ' done' ) {
51
51
// Get this url from response in real world.
52
52
getBase64 (info .file .originFileObj , (imageUrl ) => {
53
53
this .imageUrl = imageUrl
54
54
this .loading = false
55
- });
55
+ })
56
56
}
57
57
},
58
- beforeUpload (file ) {
59
- const isJPG = file .type === ' image/jpeg' ;
58
+ beforeUpload (file ) {
59
+ const isJPG = file .type === ' image/jpeg'
60
60
if (! isJPG) {
61
- this .$message .error (' You can only upload JPG file!' );
61
+ this .$message .error (' You can only upload JPG file!' )
62
62
}
63
- const isLt2M = file .size / 1024 / 1024 < 2 ;
63
+ const isLt2M = file .size / 1024 / 1024 < 2
64
64
if (! isLt2M) {
65
- this .$message .error (' Image must smaller than 2MB!' );
65
+ this .$message .error (' Image must smaller than 2MB!' )
66
66
}
67
- return isJPG && isLt2M;
67
+ return isJPG && isLt2M
68
68
},
69
69
},
70
70
}
71
71
</script >
72
- <style scoped >
72
+ <style >
73
73
.avatar-uploader > .ant-upload {
74
74
width : 128px ;
75
75
height : 128px ;
76
76
}
77
+ .ant-upload-select-picture-card i {
78
+ font-size : 32px ;
79
+ color : #999 ;
80
+ }
81
+
82
+ .ant-upload-select-picture-card .ant-upload-text {
83
+ margin-top : 8px ;
84
+ color : #666 ;
85
+ }
77
86
</style >
78
87
```
79
88
0 commit comments