当前位置 : 主页 > 手机开发 > cordova >

cordova – phonegap设置资产文件的根目录

来源:互联网 收集:自由互联 发布时间:2021-06-10
我看到的问题很少,但我发现它们不老,没有任何解决方案. 所以我是我的资产文件夹,我有以下树: - ressources - img - logo.png - css - style.css - process1 - page1.html - index.html 当我包含img / logo.png或
我看到的问题很少,但我发现它们不老,没有任何解决方案.

所以我是我的资产文件夹,我有以下树:

- ressources
  - img
     - logo.png
  - css
     - style.css
 - process1
  - page1.html
 - index.html

当我包含img / logo.png或css / style.css时,我的“index.html”一切正常.

但是要在“page1.html”中获得相同的结果,我必须使用../img/logo.png并且它非常烦人,因为我有很多页面.

我找到了两个难看的解决方案:

>复制每个子文件夹中的“ressources”文件夹
>创建一个脚本,将每个操作系统的所有URL更改为根目录(file:/// android_asset / www / for android)

也许解决方案是使用 base tag女巫允许您为所有亲属链接设置默认基础.
所以对于android来说它将是:

<base href="file:///android_asset/www/" target="_blank">

你所有的链接将是:

<img src="img/logo.png">
网友评论