大佬教程收集整理的这篇文章主要介绍了node.js – 节点JS不断加载资源错误消息,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<link rel="stylesheet" href="assets/css/formalize.css" /> <script src="assets/js/jquery.formalize.js"></script>
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/assets/css/formalize.css Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/assets/js/jquery.formalize.js
知道我哪里错了吗?这是我到目前为止的代码(在app.js中)
var express = require('express'),app = express(),server = require('http').createServer(app),io = require('socket.io').listen(server); server.listen(3000); app.get('/',function(req,res) { res.sendfile(__dirname + '/index.htm'); }); io.sockets.on('connection',function(socket) { socket.on('send message',function(data) { io.sockets.emit('new message',data); }); });
例如,如果您的目录结构设置如下:
app.js index.htm static assets js jquery.formalize.js css formalize.css
您可以像这样指定静态资产目录:
app.use(express.static(__dirname + '/static'));
<link rel="stylesheet" href="/assets/css/formalize.css"/> <script src="/assets/js/jquery.formalize.js"></script>
以上是大佬教程为你收集整理的node.js – 节点JS不断加载资源错误消息全部内容,希望文章能够帮你解决node.js – 节点JS不断加载资源错误消息所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。