我试过这个:
this.item = this.params.get('filename');
console.log("[INFO] Opening File: >" + this.item + "<");
this.textboxContent = this.file.readAsText(this.file.dataDirectory, this.item);
console.log("[INFO] Content of textboxContent: >" + this.textboxContent + "<");
但是我进入了 logcat:
[INFO:CONSOLE(56865)] "[INFO] Content of textboxContent: >[object Promise]<"
这个项目是:
[INFO:CONSOLE(56863)] "[INFO] Opening File: >SomeFile.txt<"
最佳答案
这是因为 readAsText 返回一个 promise 。你应该这样做
this.file.readAsText(this.file.dataDirectory, this.item).then((content)=>
{
this.textboxContent = content;
})
关于android - 如何使用 Ionic 3 将文本文件的内容作为字符串获取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44820961/