问题
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