const reader = new FileReader();
reader.onload = function (e) { // 当读取操作完成时触发
const imgUrl = e.target.result;
// 这里处理文件内容
handleUploadSuccess(imgUrl);
};
reader.readAsDataURL(file);
reader.readAsDataURL(file);
最后这句话很重要,虽然是在onload里面读取的,但是没有最后这个,reader会一直status为0!