Node.js 为什么我的CSS格式在节点中不起作用?
我的节点代码遇到了一些问题。所以我想在端口3000上创建一个本地服务器。在我链接我的html代码之后Node.js 为什么我的CSS格式在节点中不起作用?,node.js,Node.js,我的节点代码遇到了一些问题。所以我想在端口3000上创建一个本地服务器。在我链接我的html代码之后 app.get("/",(req,res,next)=> { res.sendfile(path.join(__dirname+'/src'+'/index.html')); }) 我的chrome浏览器显示: Refused to apply style from 'http://localhost:3000/app.css' because its MIME type ('t
app.get("/",(req,res,next)=> {
res.sendfile(path.join(__dirname+'/src'+'/index.html'));
})
我的chrome浏览器显示:
Refused to apply style from 'http://localhost:3000/app.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
另外,我的CSS不起作用。这是我的HTML中的CSS标记
<link href="./app.css" rel="stylesheet" type="text/css" />
有人知道怎么修吗?非常感谢你 要为静态文件(如图像、CSS文件和JavaScript文件)提供服务,请使用express中的express.static内置中间件函数
var express = require('express');
var app = express();
app.use(express.static('public'));
阅读更多关于的信息,非常感谢!问题解决了!