Commit cfdc1d79 authored by 张伯涛's avatar 张伯涛

上传限制完善

parent 0723d45d
......@@ -164,7 +164,7 @@
<el-upload
class="avatar-uploader"
action="#"
accept=".png,.jpg,.jpeg,.PNG,.JPG,.JPEG"
:http-request="handleUpload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
......@@ -331,6 +331,18 @@ export default {
},
beforeAvatarUpload(file) {
// this.file = file
// 判断文件是否为图片类型
const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
const isLt2M = file.size / 1024 / 1024 < 2
if (!isJPG) {
this.$message.error('只能上传图片格式的文件!')
return false
}
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 2MB!')
return false
}
this.file = file
},
step(index) {
......
......@@ -72,6 +72,7 @@
]"
>
<el-upload
accept=".png,.jpg,.jpeg,.PNG,.JPG,.JPEG"
class="avatar-uploader"
action="#"
:http-request="handleUpload"
......
......@@ -165,6 +165,7 @@
<el-col :span="12">
<el-form-item label="封面:" prop="contestPicture">
<el-upload
accept=".png,.jpg,.jpeg,.PNG,.JPG,.JPEG"
class="avatar-uploader"
action="#"
:http-request="handleUpload"
......
......@@ -189,6 +189,7 @@
</el-form-item>
<el-form-item label="图片:" prop="url">
<el-upload
accept=".png,.jpg,.jpeg,.PNG,.JPG,.JPEG"
:show-file-list="false"
list-type="picture-card"
action="#"
......
......@@ -89,6 +89,7 @@
<el-col :span="8">
<el-form-item label="封面:">
<el-upload
accept=".png,.jpg,.jpeg,.PNG,.JPG,.JPEG"
:disabled="secondFromDisabled"
class="avatar-uploader"
action="#"
......
......@@ -162,6 +162,7 @@
v-model="form.avatarId"
class="avatar-uploader"
action="#"
accept=".png,.jpg,.jpeg,.PNG,.JPG,.JPEG"
:show-file-list="false"
:file-list="photoList"
:on-change="changePhotoFile"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment