| | |
| | | type: Number, |
| | | default: () => null |
| | | }, |
| | | size: { |
| | | type: Number, |
| | | default: () => 1 |
| | | }, |
| | | uploadData: Object |
| | | }, |
| | | data () { |
| | |
| | | beforeUpload (file) { |
| | | this.$emit('beginUpload') |
| | | const isJPGOrPNG = file.type === 'image/jpeg' || file.type === 'image/png' |
| | | const isLt2M = file.size / 1024 / 1024 < 1; // 500kb |
| | | const isLt2M = file.size / 1024 / 1024 < this.size; |
| | | if (!isJPGOrPNG) { |
| | | this.$message.error('上传头像图片只能是 JPG/PNG 格式!'); |
| | | return false |
| | | } |
| | | if (!isLt2M) { |
| | | this.$message.error('上传头像图片大小不能超过 500KB!'); |
| | | this.$message.error(`上传图片大小不能超过${this.size}mb!`); |
| | | return false |
| | | } |
| | | return true |