我正在使用jquerymobile/phonegap/cordova(2.0)开发移动应用程序.我尝试从流(xml)下载一些文件并在本地存储它们.此行为仅出现在chrome浏览器中,我用它进行调试(带有涟漪效应).
如何启动chrome?开始了 :
/ Applications/Google\Chrome.app/Contents/MacOS/Google\Chrome --disable-web-security --allow-file-access-from-files --allow-file-access
我在Mac上开发我的plist文件也有访问权限*我添加<feature name="http://api.phonegap.com/1.0/file"/>到我的config.xml
我尝试使用以下代码下载一些图片:
function downloadImage(url,filename,use){
if(use==="thumb") {
filename = filename + ".png";
download(url, filename);
}return filename; }
function download(url, filename) {
//writeLog(window.appRootDir.fullPath);
ft = new FileTransfer();
ft.download(
url,
window.appRootDir.fullPath + "/" + filename,
{},
{});
}
Run Code Online (Sandbox Code Playgroud)
在模拟器上工作正常但在chrome中它失败并出现以下错误:
TypeError
ripple.js:477
TypeError: Cannot call method 'download' of undefined
at n.exports.exec (chrome-extension://geelfhphabnejjhdalkjhgipohgpdnoc/ripple.js:477:26724)
at FileTransfer.download (http://localhost/~binderf/www/a4/cordova-2.2.0.js:2753:5)
at download (http://localhost/~binderf/www/a4/js/index.js:194:5)
at downloadImage (http://localhost/~binderf/www/a4/js/index.js:182:9)
at Element.<anonymous> (http://localhost/~binderf/www/a4/js/index.js:153:51)
at Function.p.extend.each (http://localhost/~binderf/www/a4/js/jquery-1.8.2.min.js:2:14477)
at p.fn.p.each (http://localhost/~binderf/www/a4/js/jquery-1.8.2.min.js:2:11151)
at Element.<anonymous> (http://localhost/~binderf/www/a4/js/index.js:145:57) …Run Code Online (Sandbox Code Playgroud) cordova ×1