页面内容
<el-upload
class="systemUpload"
action="#"
:before-upload="handleBefore"
:show-file-list="showfile"
>
<el-button size="small" icon="el-icon-upload2"
>上传证书</el-button
>
</el-upload>
js内容
handleBefore(file) {
let base64 = null;
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = (e) => {
base64 = e.target.result; //因为后台不需要转成base64位后的开头,所以在这里截取一下
base64 = base64.split(",");
this.editForm.vcert = base64[1];
};
return false
},