200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 用nodejs中html不显示css Node.js的为什么页面无法加载css和javascript文件?

用nodejs中html不显示css Node.js的为什么页面无法加载css和javascript文件?

时间:2020-09-01 05:02:25

相关推荐

用nodejs中html不显示css Node.js的为什么页面无法加载css和javascript文件?

我创建了一个node.js服务器.当我使用端口3000进入localhost时,它只显示没有css或

javascript的文本.我尝试过几种可以解决其他问题的解决方案.但他们没有为我工作.

我的文件顺序是这样的

server.js

index.html

public

css

style.css

这是服务器的代码

var express = require(express);

var app = express();

app.get(/, function(req, res) {

res.sendFile(__dirname + /index.html);});

app.use(express.static(__dirname + public));

app.listen(3000);

这些是错误

GET http://localhost:3000/ [HTTP/1.1 304 Not Modified 11ms]

GET http://localhost:3000/public/css/demo.css [HTTP/1.1 404 Not Found 10ms]

GET http://localhost:3000/public/css/themes/popclip.css [HTTP/1.1 404 Not Found 10ms]

GET http://localhost:3000/public/css/reveal.min.css [HTTP/1.1 404 Not Found 19ms]

GET http://localhost:3000/public/css/theme/default.css [HTTP/1.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。