0

Im currently in the process of porting a completely static site using trigger io to convert it to an app. The site comprises of lots of folders in folders with index.html files in them to make the urls nice. The site uses absolute urls to include stylesheets, javascripts, on a tags, and images in every page.

I would like to set a root directory for trigger.io, but I cannot find any way of doing this. Is this even possible?

Cheers,

Rich

Edit:

Example:

<script src="/json.js" type="text/javascript"></script>
<img alt="Bar_hat" class="bar_hat" src="/assets/bar_hat-09efbabebef04dd368425a6b71badfa7.jpg" />

The script tag is in all of the files.

The img tag is used in 90% of the files. These are obviously not being found from within the app.

4

1 回答 1

1

将您的“assets”目录复制到“src”目录并在资产前使用不带“斜杠”的 -

<img alt="Bar_hat" class="bar_hat" src="assets/bar_hat-09efbabebef04dd368425a6b71badfa7.jpg" />

此外,如果您想通过 javascript 访问,则必须使用此模式:

forge.file.getUrl("assets/bar_hat-09efbabebef04dd368425a6b71badfa7.jpg", 
   function(file) {
      //  If using zepto or jquery
      $("#whateverImage").attr("src", file);
   }, 
   function(err) {
     // error
   }
);

编辑:getUrl 与 getLocal

于 2012-09-19T14:43:36.170 回答