nodejs+express 怎么引入css文件啊?
varexpress=require("express");varejs=require('ejs');varpath=require("path");varapp=ex...
var express = require("express");
var ejs = require('ejs');
var path = require("path");
var app = express();
app.set('view engine', 'ejs');
app.engine('html', ejs.__express);
app.use(express.static(path.join(__dirname,'/styles')));
app.get("/",function(req,res){
res.render("index",{title:"首页"});
});
app.get("/reg",function(req,res){
console.log(req.url)
res.render("reg",{title : "用户注册"});
});
app.use(function(req,res){
res.end("404 error!");
});
app.listen(8080,function(){
console.log("the sever has been started");
})
http://127.0.0.1:8080/styles/bootstrap.min.css 报错:404 error!
但是目录的路径是对的啊。。 展开
var ejs = require('ejs');
var path = require("path");
var app = express();
app.set('view engine', 'ejs');
app.engine('html', ejs.__express);
app.use(express.static(path.join(__dirname,'/styles')));
app.get("/",function(req,res){
res.render("index",{title:"首页"});
});
app.get("/reg",function(req,res){
console.log(req.url)
res.render("reg",{title : "用户注册"});
});
app.use(function(req,res){
res.end("404 error!");
});
app.listen(8080,function(){
console.log("the sever has been started");
})
http://127.0.0.1:8080/styles/bootstrap.min.css 报错:404 error!
但是目录的路径是对的啊。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询