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