<el-upload
:before-upload="beforeAvatarUpload">
</el-upload>
<script>
export default {
data() {
return {
};
},
methods: {
beforeAvatarUpload(file) {
const isSVG = file.type === 'image/svg+xml';//重点在这!!!
if (!isSVG) {
this.$message.error('上传图片只能是 SVG 格式!');
}
return isSVG;
}
}
}
</script>