更新时间:2021-12-27 04:03:20
app.css 应该从 /client
目录提供.将href
改成如下
app.css should be served from /client
dir. Change href
as below
href="/client/app.css">
在您的情况下,浏览器无法找到 app.css 并且浏览器可能会收到如下类似的响应
In your case browser is not able to found the app.css and browser might be receiving a similar response as below
这显然不是 CSS 文件的有效响应和 Mime 类型.这就是您收到上述错误的原因.
Which is clearly not a valid response and Mime-type for CSS file. That's why you are getting the above error.
正如您定义的静态内容如下
As you have defined static content to be served as below
app.use("/client", express.static(__dirname + "/client"));
将 href
/app.css
更改为 /client/app.css
将解决您的问题,前提是该目录中存在 app.css.
Changing href
/app.css
to /client/app.css
will solve your issue provided app.css is present in that directory.