以下是settings.py
的一部分:
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
HTML模板:
{% load staticfiles %}
...
<head>
<title>HelpDesk System</title>
<script scr="{% static "js/vendor/jquery.js" %}" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}">
<script scr="{% static "js/foundation.min.js" %}" type="text/javascript"></script>
</head>
<body>
<script>
$(document).ready(function() {
$(document).foundation();
});
</script>
...
</body>
静态文件夹树:
结果:
Css文件按预期加载,但js确实发生错误并发生错误:Can't find variable: $
答案 0 :(得分:5)
您的脚本标记看起来包含指定源的错误属性。
<script src="{% static "js/vendor/jquery.js" %}" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}">
<script src="{% static "js/foundation.min.js" %}" type="text/javascript"></script>