10
我用科尔多瓦文件的插件 - cordova file plugin读取文件中使用科尔多瓦文件插件
实际上,我从阅读文本文件的文件。下面是我的代码
document.addEventListener("deviceready", function() {
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + "sameple.txt", gotFile, fail);
}, true);
function gotFile(file) {
file.file(function (file) {
var reader = new FileReader();
reader.onloadend = function (evt) {
console.log(this.result);
}
reader.readAsText(file);
}, fail());
}
function fail(e) {
console.info("FileSystem Error : " + e);
}
所以每当我运行这段代码,我提示以下错误:
deviceready has not fired after 5 seconds.
Channel not fired: onPluginsReady
Channel not fired: onCordovaReady
Could not get Cordova FileSystem: Error: deviceready has not fired after 5 seconds.
"Could not get Cordova FileSystem:"
{
[functions]: ,
__proto__: { },
description: "deviceready has not fired after 5 seconds.",
message: "deviceready has not fired after 5 seconds.",
name: "Error"
}
{"data":"data"}
后deviceready error
后来我能够得到确切的数据..请问该如何解决这个错误?我是否必须等待设备准备好执行才能完成?
你在源文件中包含cordova.js文件吗? – Gandhi
对此有何更新? – Gandhi