📅  最后修改于: 2022-03-11 15:02:37.200000             🧑  作者: Mango
changeFile(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
uploadFile(event) {
if (event.target.value) {
const file = event.target.files[0];
const type = file.type;
this.changeFile(file).then((base64: string): any => {
console.log(base64);
this.fileBlob = this.b64Blob([base64], type);
console.log(this.fileBlob)
});
} else alert('Nothing')
}