// get the file in Base64
function getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
var storeInTheGlobalVariable = '';
var ImageBase64 = getBase64(bottomBannerImage).then(function(data){
storeInTheGlobalVariable = data; // not woking -> undefine
console.log(data) // working fine
});
我不想管理日志。我要诺言解决数据。我如何在then()方法之外获取它