| | |
| | | } |
| | | }, |
| | | methods: { |
| | | checkImageFormat(url) { |
| | | const img = new Image(); |
| | | img.onload = function() { |
| | | console.log('图片加载成功,格式正确'); |
| | | }; |
| | | img.onerror = function() { |
| | | console.log('图片加载失败,格式不支持'); |
| | | }; |
| | | img.src = url; |
| | | }, |
| | | handleAvatarSuccess(res, file) { |
| | | this.imgStatus = false; |
| | | this.form.img1key = res.data.url; |
| | | }, |
| | | beforeAvatarUpload(file) { |
| | | const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; |
| | | if (!isJpgOrPng) { |
| | | this.$message.error('只能上传 JPG 或 PNG 格式的图片!'); |
| | | } |
| | | return isJpgOrPng; |
| | | this.imgStatus = true; |
| | | }, |
| | | handleError() { |
| | |
| | | this.form.img2key = res.data.url; // URL.createObjectURL(file.raw); |
| | | }, |
| | | beforeAvatarUpload2(file) { |
| | | const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; |
| | | if (!isJpgOrPng) { |
| | | this.$message.error('Only images in JPG or PNG format can be uploaded!'); |
| | | } |
| | | return isJpgOrPng; |
| | | this.imgStatus2 = true; |
| | | const isLt10M = file.size / 1024 / 1024 < 10; |
| | | if (!isLt10M) { |