<input ref="uploadInput"
type="file"
name="file"
class='upinp'
value=""
accept="image/gif,image/jpeg,image/jpg,image/png"
@change="selectImg($event)"/>
selectImg(e){
const imgFile = e.target.files[0];
if (imgFile) {
const isLt1M = imgFile.size / 10240 / 10240 < 10;
if (!isLt1M) {
this.$message.error('上传图片大小不能超过10Mb!');
return
}
let that = this;
const reader = new FileReader();
reader.readAsDataURL(imgFile);
reader.onload = () => {
that.$message.success('上传图片成功');
that.showimageUrl=reader.result;
that.imageUrl=reader.result.replace(/^data:image\/\w+;base64,/, '');
that.$refs.uploadInput.value=null;
};
}
},