css不使用express .ejs nodejs加载属性

各位晚上好,

我将不胜感激任何帮助。

我得到了这两条路线:

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文件。 但是,当我点击index.ejs链接:a href =“/ registration / add”>,它将我带到clientRegistration.ejs页面,但registration.css不加载,即使我有:link rel =“stylesheet” type =“text / css”href =“registration.css”

我究竟做错了什么?

谢谢你的时间。

也许缺less/是一个问题

 <link rel="stylesheet" type="text/css" href="/registration.css"> 

尝试在style.css href之前添加正斜杠。 在我看来,一切都设置正确,它可能只是当前文件夹引用的问题。