Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 为什么我的CSS格式在节点中不起作用?_Node.js - Fatal编程技术网

Node.js 为什么我的CSS格式在节点中不起作用?

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

我的节点代码遇到了一些问题。所以我想在端口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 ('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'));

阅读更多关于

的信息,非常感谢!问题解决了!