|  | @@ -7,7 +7,7 @@
 | 
	
		
			
				|  |  |                       :headers="headers"
 | 
	
		
			
				|  |  |                       :show-file-list="false"
 | 
	
		
			
				|  |  |                       v-loading="uploadImgLoading"
 | 
	
		
			
				|  |  | -                     accept=".jpg, .jpeg, .png"
 | 
	
		
			
				|  |  | +                     :accept="accept"
 | 
	
		
			
				|  |  |                       :on-success="handleImgSuccess"
 | 
	
		
			
				|  |  |                       :on-error="handleUploadImgError"
 | 
	
		
			
				|  |  |                       :before-upload="beforeImgUpload">
 | 
	
	
		
			
				|  | @@ -37,6 +37,12 @@ export default {
 | 
	
		
			
				|  |  |              // 组件状态
 | 
	
		
			
				|  |  |              type: String,
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  | +        accept: {
 | 
	
		
			
				|  |  | +            type: String,
 | 
	
		
			
				|  |  | +            default() {
 | 
	
		
			
				|  |  | +                return 'jpg, .jpeg, .png'
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  |          imageSizeM: { // 默认2M
 | 
	
		
			
				|  |  |              type: Number,
 | 
	
		
			
				|  |  |              default() {
 | 
	
	
		
			
				|  | @@ -54,17 +60,18 @@ export default {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    mounted() {},
 | 
	
		
			
				|  |  | +    mounted() {
 | 
	
		
			
				|  |  | +        this.imgUrl = this.value
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |      methods: {
 | 
	
		
			
				|  |  |          beforeImgUpload (file) {
 | 
	
		
			
				|  |  |              const isImage = this.imageType[file.type];
 | 
	
		
			
				|  |  |              const isLt2M = file.size / 1024 / 1024 < this.imageSizeM;
 | 
	
		
			
				|  |  | -            console.log(isImage, isLt2M)
 | 
	
		
			
				|  |  |              if (!isImage) {
 | 
	
		
			
				|  |  |                  this.$message.error("只能上传图片格式!");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (!isLt2M) {
 | 
	
		
			
				|  |  | -                this.$message.error("上传图片大小不能超过 2MB!");
 | 
	
		
			
				|  |  | +                this.$message.error(`上传图片大小不能超过 ${isLt2M}MB!`);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (isImage && isLt2M) {
 | 
	
		
			
				|  |  |                  this.uploadImgLoading = true
 | 
	
	
		
			
				|  | @@ -83,7 +90,6 @@ export default {
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      watch: {
 | 
	
		
			
				|  |  |          value(newValue) {
 | 
	
		
			
				|  |  | -            console.log(newValue);
 | 
	
		
			
				|  |  |              this.imgUrl = newValue
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |      },
 |