gpt4 book ai didi

javascript - lite-server 未在/js 文件夹内提供 .js 文件 - 浏览器不请求/js 文件

转载 作者:行者123 更新时间:2023-12-03 04:49:13 25 4
gpt4 key购买 nike

我正在使用 npm run lite 运行 lite-server

我的 jQuery 文件正在正常加载,css 文件夹中的 css 也正常加载,但浏览器甚至没有对 main.js 文件发出 GET 请求。

main.js 文件位于/js 文件夹内,与/css 文件夹中的 style.css 一样

我错过了什么吗?

这是我的 HTML

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" scr="js/main.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
test
</body>
</html>

编辑: -> 刚刚意识到浏览器没有对此文件发出 GET 请求。而且如果我直接向 js 文件发出请求,服务器也会返回它。

index.html request main.js request

并且npm run lite正在运行:

$ npm run lite

> sdfa@1.0.0 lite C:\temp\nodeIntro
> lite-server

Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
** browser-sync config **
{ injectChanges: false,
files: [ './**/*.{html,htm,css,js}' ],
watchOptions: { ignored: 'node_modules' },
server: { baseDir: './', middleware: [ [Function], [Function] ] } }
[BS] Access URLs:
------------------------------------
Local: http://localhost:3000
External: http://192.168.1.4:3000
------------------------------------
UI: http://localhost:3001
UI External: http://192.168.1.4:3001
------------------------------------
[BS] Serving files from: ./
[BS] Watching files...
17.03.11 12:52:27 304 GET /index.html
17.03.11 12:52:27 304 GET /node_modules/jquery/dist/jquery.min.js
17.03.11 12:52:27 304 GET /node_modules/jquery/dist/jquery.js
17.03.11 12:52:27 304 GET /css/style.css

最佳答案

您错过了scrsrc输入

错误

正确

<script type="text/javascript" src="js/main.js"></script>

关于javascript - lite-server 未在/js 文件夹内提供 .js 文件 - 浏览器不请求/js 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42738819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com