window.resolveLocalFileSystemURI is not a function

允我心安 提交于 2020-08-22 16:45:05

问题


I created a web application that I need to convert to a mobile application, now all I have is html5/js/css files which means I don't have any www foder no platforms folder, not a cordova project ... I started first to build the app using cordova command lines, but I couldn't, I found many problems on that, I used then https://build.phonegap.com/ , and it works fine for me. In order to read the file, I have tried this code :

    window.resolveLocalFileSystemURI("file:///android_asset/www/data/User.xml", function () {
        alert("Success");
    }, function () {
        alert(" error ");
    });

but, it didn't work. I added a try catch, the exception was :

window.resolveLocalFileSystemURI is not a function

Do i need to add something to my code to make it work ?


回答1:


You need to install a plugin for this to work.

Basically, run "cordova plugin add org.apache.cordova.file" at your application's root directory.

For detailed instructions see here, under "Accessing the Feature": http://docs.phonegap.com/en/edge/cordova_file_file.md.html#LocalFileSystem

UPDATE 2019

The correct way to add this plugin is now with this command in your project root:

cordova plugin add cordova-plugin-file

This is a core cordova plugin. Documentation found here on npm



来源:https://stackoverflow.com/questions/29965452/window-resolvelocalfilesystemuri-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!