![](/img/trans.png)
[英]How do you import a js file using {% load staticfiles%} in a base html template
[英]How do you import a local js file into a basic html file?
I have a very basic html file that uses a script tag to import a javascript file, but the javascript file is not run when I load the html locally in a browser. 我如何錯誤地格式化腳本標簽?
文件夾結構
-folder
--test.html
--script.js
測試.html
<html lang="en">
<head>
<meta charset="utf-8">
<title>TEST</title>
</head>
<body>
<p>TEST</p>
<script type='text/javascript' src="script.js" />
</body>
</html>
腳本.js
console.log('HELLO WORLD')
(function () {
setTimeout(() => alert('HELLO WORLD'), 3000)
})();
您應該在單獨的標簽中關閉您的腳本標簽:
<script type="text/javascript" src="script.js"></script>
您的腳本標簽不正確,應該是: <script type='text/javascript' src="script.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.