簡體   English   中英

如何獲取存儲在應用程序包中的javascript文件(JS)路徑到文檔目錄中存在的html文件

[英]How to get the javascript file (JS) path which is stored in application bundle to html file which is there in document directory

I have one .js file named final.js which I copied as bundle resource I have a requirement like the html document which reads this js file should download at runtime and store it in documents directory. But the js file is not able to read by the html when I loaded it in webview, because of the path of .js file.

I tried with the solution like below, but not worked.

<script src ="./final.js"> </script>

最后,我嘗試復制如下所示的應用程序捆綁包的硬編碼路徑,現在它可以正常工作了。 最后,我知道這條路是不正確的。

> <script src ="/Users/unknownUser/Library/Application Support/iPhone
> Simulator/7.0/Applications/025EF3B6-F2E6-4162-8921-839D7D98FF58/HTMLGetdataTestApp.app/final.js">
> </script>`

任何人都可以告訴我,存儲在documents目錄中的html文件如何讀取具有正確路徑而不是上面的硬編碼存儲在主捆綁包中的.js文件。

簡單的解決方案是將final.js文件復制到documents目錄。

將js文件從分發包復制到文檔目錄(html頁面所在的位置),並將路徑設置為:

<script src ="final.js"> </script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM