Cordova文件插件不工作

Cordova file plugin doesn't work

本文关键字:工作 插件 文件 Cordova      更新时间:2023-09-26

我在我的项目中使用cordova 5.1.1。我在cordova_plugins.js文件插件的声明:

{
    "file": "plugins/cordova-plugin-file/www/FileSystem.js",
    "id": "cordova-plugin-file.FileSystem",
    "clobbers": [
        "window.FileSystem"
    ]
},

但是当我尝试这样使用插件时:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
        onFileSystemSuccess, fail);

:

Uncaught ReferenceError: LocalFileSystem is not defined

没有响应侦听器所以文件插件没有加载这就是为什么你得到

Uncaught ReferenceError: LocalFileSystem is not defined

加上这个,并把你的请求包含进去:

document.addEventListener("deviceready", function() { 
  //use request file here
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
        onFileSystemSuccess, fail);
}, false);