I am using javascript FileReader() in Vue.js now. but something problem. when i printed that "this.currentUrl" in onload function, it returns very well. but out of load functions, it returns blank! what's the problem? and how can i fix it ㅠㅠ??
data: function () {
return {
currentUrl: ''
}
},
addImages() {
var reader = new FileReader();
reader.onload = (e) => {
this.currentUrl = reader.result
console.log(this.currentUrl)
/* it returns well */
}
console.log(this.currentUrl);
/* it returns blank */
reader.readAsDataURL(event.target.files[0])
},
Thank you