diff --git a/litemall-admin/src/views/promotion/ad.vue b/litemall-admin/src/views/promotion/ad.vue index d90715bc..9df2d302 100644 --- a/litemall-admin/src/views/promotion/ad.vue +++ b/litemall-admin/src/views/promotion/ad.vue @@ -60,10 +60,12 @@ :action="uploadPath" :show-file-list="false" :on-success="uploadUrl" + :before-upload="checkFileSize" class="avatar-uploader" accept=".jpg,.jpeg,.png,.gif"> +
只能上传jpg/png文件,且不超过1024kb
@@ -218,6 +220,13 @@ export default { uploadUrl: function(response) { this.dataForm.url = response.data.url }, + checkFileSize: function(file) { + if (file.size > 1048576) { + this.$message.error(`${file.name}文件大于1024KB,请选择小于1024KB大小的图片`) + return false + } + return true + }, createData() { this.$refs['dataForm'].validate(valid => { if (valid) {