简体   繁体   English

ejs文件无法应用样式表

[英]ejs file can't apply style sheet

I'm working on a website and the CSS file seemingly at random stopped being applied to the ejs file I was working on. 我正在网站上工作,而CSS文件似乎已停止随机应用于我正在处理的ejs文件。 The links work (in this because I can follow the link in vs code) yet the CSS file won't load. 链接有效(因为我可以按照vs代码中的链接进行操作),但CSS文件不会加载。

I've tried changing the paths but to no avail and the CSS file is applied to the ejs file when I run it in sublime but not in vs code. 我试过更改路径但无济于事,当我以崇高的态度运行它而不是在vs代码中运行时,CSS文件被应用于ejs文件。 The file tree looks like this: 文件树如下所示:

1 Project
-- 1.1 public
   -- 1.1.1 demos.css
-- 1.2 views
   -- 1.2.1 demos.ejs

EJS (demos.ejs) EJS(demos.ejs)

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

CSS (demos.css) CSS(demos.css)

body { 
    background: url(images/About-bg.png) no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    padding-top: 80px;
}

On the console of inspect element on chrome it says: 在chrome上的inspect元素的控制台上说:

Refused to apply style from ' http://localhost:8081/demos/demos.css ' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. 拒绝从' http:// localhost:8081 / demos / demos.css '应用样式,因为它的MIME类型('text / html')不是受支持的样式表MIME类型,并且启用了严格的MIME检查。

Idk if anyone else has this type of problem but I fixed it by making a demos folder in the public folder because that where the ejs file is looking for some reason. 如果其他人遇到这种类型的问题,则可确定,但我通过在公共文件夹中创建一个demos文件夹来解决此问题,因为该ejs文件出于某种原因正在查找。

Hope this helps someone! 希望这对某人有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM