为什么我的代码不像appache服务器?它正确链接并打印html,但图像无法正确加载。我错过了什么?
var express = require('express');
var app = express();
var path = require('path');
app.get('/:path', function(req, res) {
var p = path.join(__dirname,"/" + req.params.path)
res.sendFile(p);
});
app.get( '*', function(req, res) {
var p = path.join(__dirname, "/index.html")
res.sendFile(p);
});
app.listen('3000', function () {
console.log('app listening on port 3000!');
})
Allso我刚注意到当我加载javascript时出现错误:
Uncaught SyntaxError: Unexpected token < //for each js file