大家晚上好,
我将不胜感激。
我有这两条路线:
app.get('/', function(req,res){
res.render('index');
});
app.get('/registration/add', function(req,res){
res.render('clientRegistration');
});
这是服务器的一部分:
app.use( express.static(path.join( __dirname, './client/static/')));
app.use(body_parser.urlencoded());
app.set( "views", path.join(__dirname, "./client/views/"));
app.set( "view engine", 'ejs');
目录是:
MyApp/
client/
static/
registration.css
styles.css
views/
index.ejs
clientRegistration.ejs
在我的index.ejs上,我有: link rel =“stylesheet”type =“text / css”href =“styles.css”可以完美地加载.css文件。但是当我点击链接时: a href =“/ registration / add”>在index.ejs上, 它将我带到clientRegistration.ejs页面,但即使我有以下情况,registration.css也不会加载: link rel =“stylesheet”type =“text / css”href =“registration.css”
我做错了什么?
感谢您的时间。
答案 0 :(得分:2)
可能缺少/
是个问题
<link rel="stylesheet" type="text/css" href="/registration.css">
答案 1 :(得分:1)
尝试在style.css
href之前添加正斜杠。在我看来,一切都设置正确,它可能只是当前文件夹引用的问题。