I使用express构建socket.io应用程序,最初在index.html中有所有CSS/JS,并使用
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendfile('index.html');
});
但现在我将CSS/JS拆分为app.css
和app.js
文件,但当我启动应用程序并访问控制台登录浏览器中的页面时,我会得到
无法加载CSS/JS的资源错误,我该怎么做才能让它也允许单独的CSS/JS?
var express = require('express'),
app = express(),
http = require('http').Server(app),
io = require('socket.io')(http);
app.use(express.static(__dirname + '/public'));
http.listen(port);
index.html将显示在http://localhost:[端口]。