express.static不渲染。我已到HTML内容的CSS文件,我是使用Ubuntu

问题描述 投票:0回答:1

this is my code express.static方法不是从公共目录渲染CSS文件,我使用Ubuntu。但HTML文件完全显示了不CSS。

node.js express
1个回答
0
投票

用这段代码替换您express.static线

//serve static files
var serveIndex = require('serve-index');
app.use('/public/', serveIndex(path.join(__dirname, 'public')));
app.use('/public/', express.static(path.join(__dirname, 'public')));
© www.soinside.com 2019 - 2024. All rights reserved.