我正在使用以下命令在 iOS 上通过 PhoneGap 获取应用程序的根文件夹。使用 Phonegap Build 构建。它在 phonegap 2.9.0 上工作正常,但在 3.1.0 上失败。有人可以指出发生了什么变化,代码可能有什么问题吗?谢谢。
function findLocalPath()
{
window.requestFileSystem(
LocalFileSystem.PERSISTENT,
0,
function onFileSystemSuccess(fileSystem)
{
fileSystem.root.getFile(
"dummy.html",
{create: true, exclusive: false},
function gotFileEntry(fileEntry)
{
var sPath = fileEntry.fullPath.replace("dummy.html","");
var fileTransfer = new FileTransfer();
fileEntry.remove();
alert(sPath);
},
fail);
},
fail);
}
在config.xml中,我已经替换
<plugin name="File" value="CDVFile" />
<plugin name="FileTransfer" value="CDVFileTransfer" />
具有以下内容,如文档所述。
<feature name="File">
<param name="ios-package" value="CDVFile" />
</feature>
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer" />
</feature>
最佳答案
在 phonegap 3.x 中,您必须使用命令行添加插件,而不是更改 config.xml
添加文件和文件传输使用这个:
cordova plugin add org.apache.cordova.file
cordova plugin add org.apache.cordova.file-transfer
它将更改 config.xml 并添加其他所需的文件。
对于 phonegap 构建,您必须在本地添加它们,然后使用以下命令在线构建它:
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git
phonegap remote build ios
关于ios - PhoneGap 3.1.0 与 2.9.0 的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20205922/