Cordova + RequireJS:如何加载File-Plugin

时间:2015-03-18 21:47:38

标签: javascript cordova requirejs cordova-plugins

我想在使用RequireJS构建的Cordova(3.6.4)应用程序中存储文件(图像)。

我制作了一个新模块,但我不知道如何使用RequireJS加载File-Plugin(org.apache.cordova.file)。 window.requestFileSystem始终未定义。我以为我必须加载FileSystem(在模块中注释)但没有任何效果......

define(function (require) {

"use strict";

var $ = require('jquery'),
    //FileSystem = require('/plugins/org.apache.cordova.file/www/FileSystem'),


download = function (URL, Folder_Name, File_Name) {
    //step to request a file system 
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, fileSystemSuccess, fileSystemFail);
},

return {
    download: download
};
});

1 个答案:

答案 0 :(得分:1)

我找到了。这是一个容易(和一点点尴尬)的。我只是忘了加载cordova脚本本身,因为我现在还不需要它......

我的应用程序现在启动以下内容,一切正常。

require(['../cordova', '../cordova_plugins'], function () {