" + this.item + "-6ren">
gpt4 book ai didi

android - 如何使用 Ionic 3 将文本文件的内容作为字符串获取?

转载 作者:行者123 更新时间:2023-11-29 19:12:29 26 4
gpt4 key购买 nike

我试过这个:

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com