Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从文件系统到文件的Phonegap iOS链接_Ios_Cordova_Filesystems_Href - Fatal编程技术网

从文件系统到文件的Phonegap iOS链接

从文件系统到文件的Phonegap iOS链接,ios,cordova,filesystems,href,Ios,Cordova,Filesystems,Href,我创建了Phonegap应用程序,它在文件系统中保存网页。当我从文件系统打开这些网页时,只加载所选的页面,而不加载相关的文件(图像、css等) 例如,文件系统中有一个网页,路径为: cdvfile://localhost/temporary/1/ 在这个目录中有如下文件:index.html、style.css、img/background.png等。 当我打开文件index.html时,仅打开此文件,但页面没有样式和图像。这些相关文件在index.html中具有相对路径 这种情况仅在iOS平

我创建了Phonegap应用程序,它在文件系统中保存网页。当我从文件系统打开这些网页时,只加载所选的页面,而不加载相关的文件(图像、css等)

例如,文件系统中有一个网页,路径为:

cdvfile://localhost/temporary/1/
在这个目录中有如下文件:index.html、style.css、img/background.png等。 当我打开文件index.html时,仅打开此文件,但页面没有样式和图像。这些相关文件在index.html中具有相对路径

这种情况仅在iOS平台上出现。在Android平台和谷歌chrome上都能正常工作。这是为什么?我能修好它吗

编辑:

我刚刚发现从文件加载的链接和js是有效的。例如:

<a href="page_b.html">link</a>

打开右侧页面。但是css像:

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <link rel="stylesheet" href="css/style.css"/>
</head>

它们都坏了

编辑:

不幸的是,这是cordova项目中的一个开放错误:

请参见


我最终使用了相对路径(比如
。/../Documents/MyApp/temporary/1/
)而不是完整路径(比如
cdvfile://localhost/temporary/1/
)修复iOS中的CSS问题。

看起来您遇到了。我只是提出了一个修复请求——您可以暂时使用我的fork,直到它被接受:

要使用它,请执行以下操作:

  cordova plugin remove org.apache.cordova.file
  cordova plugin add https://github.com/loufranco/cordova-plugin-file.git
如果拉取请求被接受,请记住将其反转