[英]Javascript not showing up on template in django
I do not understand why my javascript files are not being applied on my templates.我不明白为什么我的 javascript 文件没有应用于我的模板。 Here is my base.html:
这是我的 base.html:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/styles.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'assets/css/main.css' %}">
</head>
<body>
<div>
{% include "navbar.html" %}
{% block content %}
{% endblock content %}
</div>
{% include "scripts.html" %}
</body>
</html>
Here is my scripts.html:这是我的scripts.html:
{% load static %}
<script src="{% static 'js/main.js' %}"></script>
<script src="{% static 'assets/js/jquery.min.js' %}"></script>
<script src="{% static 'assets/js/jquery.dropotron.min.js' %}"></script>
<script src="{% static 'assets/js/browser.min.js' %}"></script>
<script src="{% static 'assets/js/breakpoints.min.js' %}"></script>
<script src="{% static 'assets/js/util.js' %}"></script>
<script src="{% static 'assets/js/main.js' %}"></script>
However, they don't seem to affect the template.但是,它们似乎不会影响模板。 For example, the dropdown menu is in a weird format if I run the server.
例如,如果我运行服务器,下拉菜单的格式很奇怪。 Another weird thing happening is that
Main.js
keeps being printed on the console.另一个奇怪的事情是
Main.js
一直在控制台上打印。 I believe this was initially because of the main.js file which had:我相信这最初是因为 main.js 文件具有:
console.log("Main.js");
However, even though I change it to the following:但是,即使我将其更改为以下内容:
console.log("Something new for the console");
I still get Main.js
printed out on the console.我仍然在控制台上打印出
Main.js
Moreover, if I put console.log("something")
for my other javascript files referenced above, they don't get printed out on the console.此外,如果我将
console.log("something")
放在上面引用的其他 javascript 文件中,它们就不会在控制台上打印出来。 I have no idea why this is happneing.我不知道为什么会这样。 Thanks, and please ask any questions.
谢谢,有任何问题请提问。
Clean up cached images and files!清理缓存的图像和文件!
If you are using Chrome, you can follow the following steps:如果您使用的是 Chrome,您可以按照以下步骤操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.