jquery mobile css does not load from local, only from web

旧巷老猫 提交于 2019-12-22 13:49:42

问题


Someone must have the answer to this, it's driving me nuts!!!

I am testing a jquery mobile page and have the following in my index.html page:

<link rel="stylesheet" href="css/jquery.mobile-1.2.0.min.css" />
<script src="js/jquery-1.8.2.min.js"></script>
<script src="js/jquery.mobile-1.2.0.min.js"></script>

It doesn't work. The page doesn't recognize the css or js. But when I load it over the network it works:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

I've copied and downloaded those files over and over to check that I have the right local files. Why would it load from an external URL but not my local files?


回答1:


If you have a js folder and a css folder in the root of your project add a leading "/". The leading slash will start you at the beginning of the domain.

<link rel="stylesheet" href="/css/jquery.mobile-1.2.0.min.css" />
<script src="/js/jquery-1.8.2.min.js"></script>
<script src="/js/jquery.mobile-1.2.0.min.js"></script>


来源:https://stackoverflow.com/questions/13980742/jquery-mobile-css-does-not-load-from-local-only-from-web

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!