资源解释为样式表但使用 MIME 类型传输 text/x-scss
Resource interpreted as Stylesheet but transferred with MIME type text/x-scss
我想用 nodejs 创建一个网站,但我在 scss
和 ejs
中的显示样式有问题。
我在文件夹 ../app/public/scss
中有一个 scss
样式,我使用这个中间件通过 express 设置静态文件:
app.use(express.static(path.join(__dirname,'public')));
app.set('view engine', 'ejs');
app.set('views' , path.join(__dirname,'../','resources/views'));
在 header 中,我通过这种方式定义样式:
<link rel="stylesheet" type="text/css" href="/scss/vazir.scss">
<link rel="stylesheet" type="text/css" href="/scss/media-queries.scss">
<link rel="stylesheet" type="text/css" href="/scss/style.scss">
我在 register.ejs :
中以这种方式使用 header
<%- include('./../header.ejs'); %>
注册
但是当我进入注册页面时,它在控制台中显示了这个:
Resource interpreted as Stylesheet but transferred with MIME type text/x-scss: "http://localhost:3000/scss/vazir.scss".
register:9 Resource interpreted as Stylesheet but transferred with MIME type text/x-scss: "http://localhost:3000/scss/media-queries.scss".
register:10 Resource interpreted as Stylesheet but transferred with MIME type text/x-scss: "http://localhost:3000/scss/style.scss".
有什么问题吗?我该如何解决这个问题????
浏览器不支持 SCSS。您需要将其编译为 CSS 并将 CSS 文件提供给浏览器。
有多种编译器支持它。 SASS 是官方的。您可能想找到一个与现有构建工具链集成的工具。
我想用 nodejs 创建一个网站,但我在 scss
和 ejs
中的显示样式有问题。
我在文件夹 ../app/public/scss
中有一个 scss
样式,我使用这个中间件通过 express 设置静态文件:
app.use(express.static(path.join(__dirname,'public')));
app.set('view engine', 'ejs');
app.set('views' , path.join(__dirname,'../','resources/views'));
在 header 中,我通过这种方式定义样式:
<link rel="stylesheet" type="text/css" href="/scss/vazir.scss">
<link rel="stylesheet" type="text/css" href="/scss/media-queries.scss">
<link rel="stylesheet" type="text/css" href="/scss/style.scss">
我在 register.ejs :
<%- include('./../header.ejs'); %>
注册
但是当我进入注册页面时,它在控制台中显示了这个:
Resource interpreted as Stylesheet but transferred with MIME type text/x-scss: "http://localhost:3000/scss/vazir.scss".
register:9 Resource interpreted as Stylesheet but transferred with MIME type text/x-scss: "http://localhost:3000/scss/media-queries.scss".
register:10 Resource interpreted as Stylesheet but transferred with MIME type text/x-scss: "http://localhost:3000/scss/style.scss".
有什么问题吗?我该如何解决这个问题????
浏览器不支持 SCSS。您需要将其编译为 CSS 并将 CSS 文件提供给浏览器。
有多种编译器支持它。 SASS 是官方的。您可能想找到一个与现有构建工具链集成的工具。