更新时间:2023-12-03 08:28:34
从答案 Express-js无法获取我的静态文件,为什么?我会建议:
From the answer Express-js can't GET my static files, why? I'd suggest:
app.use("/client", express.static(__dirname + '/client'));
这是因为您的:
This is needed because your:
app.get ('/', function (req,res) {
res.render('index.html');
});
只能解决当有人前往 / $ c $时发生的情况c>并说应该提供index.html。这本身并不适用于其他任何事情。
is only addressing what happens when someone goes to /
and saying that index.html should be served. That alone doesn't serve anything else.