Mah*_*iya 6 ios cordova cordova-3
我有一段使用Cordova 2.7的代码.我将我的应用程序升级到Cordova 3.3,同时升级了我开发的所有自定义插件.
我成功地使用Cordova 2.7获得iOS上Documents文档目录的完整绝对路径,但是使用Cordova 3.3它只返回/fullPath
这是我的代码:
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
function gotFS(fileSystem) {
alert("entered gotFS: " + fileSystem.root.fullPath);
}
Run Code Online (Sandbox Code Playgroud)
我在iPad模拟器7.0上测试了这个(用Cordova 2.7给出了正确的结果)
虽然,我可以通过其他方法获得路径,但我更喜欢使用Cordova API.
API文档没有提及任何相关内容.知道什么可能是错的吗?
尝试改变fullpath,以toURL()和测试
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
function gotFS(fileSystem) {
alert("entered gotFS: " + fileSystem.root.toURL());
}
Run Code Online (Sandbox Code Playgroud)
由于很少有用户请求我的答案,这是我设法获取Documents目录路径的方式:
var documentsDirectoryPath = decodeURIComponent(window.location.href);
documentsDirectoryPath = documentsDirectoryPath.substring("file://".length);
documentsDirectoryPath = documentsDirectoryPath.substring(0, documentsDirectoryPath.indexOf("/<<YOUR_APP_NAME>>.app/www/index.html"));
documentsDirectoryPath += "/Documents";
Run Code Online (Sandbox Code Playgroud)
请务必使用您应用的名称替换YOUR_APP_NAME
| 归档时间: |
|
| 查看次数: |
8063 次 |
| 最近记录: |