更改品种上传图片大小限制

This commit is contained in:
Songsl 2026-06-13 15:17:36 +08:00
parent 2ffba07c0c
commit 7e117b176d
1 changed files with 5 additions and 5 deletions

View File

@ -40,7 +40,7 @@
:before-upload="beforeUpload" :limit="1" :on-exceed="handleExceed"> :before-upload="beforeUpload" :limit="1" :on-exceed="handleExceed">
<el-button type="primary">点击上传</el-button> <el-button type="primary">点击上传</el-button>
<template #tip> <template #tip>
<div class="el-upload__tip">jpg/png格式 图片大小不能超过20KB</div> <div class="el-upload__tip">jpg/png格式 图片大小不能超过200KB</div>
</template> </template>
<img v-if="dialogType === 'edit'" :src="formData.imageUrl" alt="预览图片" style="width: 100px; height: 100px" /> <img v-if="dialogType === 'edit'" :src="formData.imageUrl" alt="预览图片" style="width: 100px; height: 100px" />
</el-upload> </el-upload>
@ -410,7 +410,7 @@ const handleExceed = (files: File[]) => {
} }
} }
// + 20KB = 20 * 1024 // + 200KB = 200 * 1024
const beforeUpload = (file: File) => { const beforeUpload = (file: File) => {
// //
const fileName = file.name.toLowerCase() const fileName = file.name.toLowerCase()
@ -429,10 +429,10 @@ const beforeUpload = (file: File) => {
return false return false
} }
// (20KB) // (200KB)
const isSizeValid = file.size / 1024 < 20 const isSizeValid = file.size / 1024 < 200
if (!isSizeValid) { if (!isSizeValid) {
ElMessage.error('图片大小不能超过 20KB!') ElMessage.error('图片大小不能超过 200KB!')
return false return false
} }