shish 6 лет назад
Родитель
Сommit
08881fe6fd
1 измененных файлов с 8 добавлено и 2 удалено
  1. 8 2
      shop/src/components/common/elx-upload.vue

+ 8 - 2
shop/src/components/common/elx-upload.vue

@@ -18,7 +18,7 @@
 			<i class="el-icon-plus"></i>
 		</el-upload>
 		<el-dialog :visible.sync="dialogVisible">
-			<img width="100%" :src="dialogImageUrl" alt="" />
+			<img width="100%" :src="dialogImageUrl" alt />
 		</el-dialog>
 	</div>
 </template>
@@ -39,7 +39,7 @@ export default {
 			default: []
 		},
 		value: [Array, String],
-		beforeUpload: Function,
+		//beforeUpload: Function,
 		disabled: Boolean,
 		category: Array
 	},
@@ -74,6 +74,12 @@ export default {
 					});
 			});
 		},
+		beforeUpload(file) {
+			if (file.size / 1024 / 1024 > 1) {
+				this.$message.warning('上传的图片不能超过1M');
+				return false;
+			}
+		},
 		handleRemove(file, fileList) {
 			this.$emit('handleRemove', { file, fileList });
 		},