【问题标题】:jquery mobile css does not load from local, only from webjquery mobile css不会从本地加载,只能从网络加载
【发布时间】:2012-12-21 05:32:02
【问题描述】:

一定有人知道这个问题的答案,我快疯了!!!

我正在测试一个 jquery 移动页面,并且在我的 index.html 页面中有以下内容:

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

它不起作用。该页面无法识别 css 或 js。但是当我通过网络加载它时它可以工作:

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

我一遍又一遍地复制和下载这些文件,以检查我是否拥有正确的本地文件。为什么它会从外部 URL 加载而不是我的本地文件?

【问题讨论】:

  • 你有相对于 index.html 所在文件夹的子文件夹 'js' 和子文件夹 'css' 吗?
  • 您能帮我们指向实时文件吗?
  • 这可能是因为您没有引用正确的 url 尝试以 '/' 开头,这意味着从域开始并根据您的域给出您的路径。
  • 这个问题是stackoverflow.com/questions/7199975/…的副本
  • 是的,我有相对于 index.html 文件夹的 js 和 css 子文件夹。实时文件位于上面链接的位置。我知道 hte index.html 正在工作,只是找不到 css。

标签: jquery css mobile


【解决方案1】:

如果您的项目根目录中有 js 文件夹和 css 文件夹,请添加前导“/”。前导斜杠将从域的开头开始。

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

【讨论】:

  • 还是没有运气。添加前导“/”似乎没有任何区别。
  • 我终于在另一篇文章中找到了答案。在本地安装这些 css 文件时,有图像文件需要与它们一起安装。它们需要位于 CSS 文件夹的子文件夹中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多