慕哥9229398
2019-03-14 15:11:46
報(bào)錯(cuò):ERROR TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.這是用ionic寫(xiě)的\\xx.html<input type="file" (change)="selectImage(this.files)" accept="image/jpeg,image/png,image/jpg">\\xx.tsselectImage(file){ var reader = new FileReader(); reader.onload = function(file){ // console.log(evt.currentTarget) } reader.readAsDataURL(file); console.log(reader.readAsDataURL(file)); }
3 回答

米脂
TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超3個(gè)贊
selectImage(event){
let reader = new FileReader();
let file = event.target.files[0];
reader.readAsDataURL(file);
reader.onload = function(){
console.log(reader.result)
}
}

MM們
TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊

繁星淼淼
TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超11個(gè)贊
我想問(wèn)下我怎么把blob轉(zhuǎn)成base64呀。我獲取的字符串為:url("blob:http://localhost:8080/cc116c31-f8f1-47b1-a87b-96d948253495")。請(qǐng)大神賜教
添加回答
舉報(bào)
0/150
提交
取消