Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExpressJS应用程序没有';无法加载CSS文件_Javascript_Html_Css_Node.js_Express - Fatal编程技术网

Javascript ExpressJS应用程序没有';无法加载CSS文件

Javascript ExpressJS应用程序没有';无法加载CSS文件,javascript,html,css,node.js,express,Javascript,Html,Css,Node.js,Express,我的ExpressJS web应用程序只加载HTML文件,但不应用CSS规则。我将HTML文件与CSS文件链接,并在app.js中添加了express.static(path.join(uu dirname,'CSS')) 这是我的项目树: app.js /views - index.html /css - style.css 如何修复此问题?请确保添加。你现在所做的就是 express.static(path.join('css')) 你应该做的是 app.use(express.stat

我的ExpressJS web应用程序只加载HTML文件,但不应用CSS规则。我将HTML文件与CSS文件链接,并在app.js中添加了
express.static(path.join(uu dirname,'CSS'))

这是我的项目树:

app.js
/views
- index.html
/css
- style.css
如何修复此问题?

请确保添加。你现在所做的就是

express.static(path.join('css'))
你应该做的是

app.use(express.static(path.join('css'))
还要确保您在HTML中引用了样式表


问题在于HTML文件中的标记。我有
src='./css/style.css'
但是使用
src='/style.css'
修复了它。

添加到HTML模板中,并确保
使用
静态目录:
app.use(express.static(path.join(\u dirname,'css'))
in-app.js