[英]using build.phonegap.com - how to reference cordova.js on pages other than index.html?
我有一個基於Adobe CQ5構建並使用build.phonegap.com進行編譯的多頁新聞應用程序。 我無法弄清楚如何從所有HTML頁面中引用cordova.js。
在index.html上使用<script src="cordova.js"></script>
很容易,但是應用程序的結構使得每篇文章在不同目錄下都是自己的HTML文件。 我無法對JS參考進行硬編碼,因為我需要將其作為<script src="../cordova.js"></script>
放在一個文件中,並將其作為<script src="../../cordova.js"></script>
,依此類推,具體取決於HTML目錄。 更不用說資產的獲取路徑,並且cordova.js在每個設備上也有所不同。
簡而言之,結構大致如下:
/www/index.html <-- referencing cordova.js through <script src="cordova.js"></script>
/www/cordova.js
/www/content/breaking-news.html <-- this page needs to reference cordova.js too
/www/content/breaking-news/breaking-news-title.html <-- this page needs to reference cordova.js too
...
etc
我該如何處理? 單頁應用程序是唯一的解決方案嗎? 我不擔心性能,因為我已經設置了contentsync系統,該系統將通過空中獲取壓縮的增量更新並將其應用於應用程序。
相對路徑,例如../cordova.js
或cordova.js
取決於引用資源的當前位置,例如index.html
或cordova.js
breaking-news.html
。 您應該使用絕對路徑: /cordova.js
。 無論當前的網頁路徑如何,它將始終從站點根目錄引用腳本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.