我想包括外部css文件在node.js的ejs。
我试过了,但不起作用:
app.use('/static', express.static('/view'))
并像这样在ejs中包含css。
<link rel="stylesheet" type="text/css" href="materialize.scss">
它总是给出这个错误
拒绝应用来自'http://localhost:8081/static/materialize.scss‘的样式,因为其MIME类型('text/html')不是支持的样式表MIME类型,并且启用了严格的MIME检查。
发布于 2018-06-09 14:26:12
您应该首先将scss编译成css。浏览器不理解scss代码。
npm install --save scss
sass static/materialize.scss static/css/materialize.css
然后添加链接:
<link rel="stylesheet" type="text/css" href="/static/css/materialize.css">
我希望它能帮上忙。
https://stackoverflow.com/questions/50771486
复制相似问题