3 回答

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超3個(gè)贊
嘗試http://localhost:3001/default.css。
要/styles在您的請(qǐng)求URL中使用:
app.use("/styles", express.static(__dirname + '/styles'));
查看此頁(yè)面上的示例:
//Serve static content for the app from the "public" directory in the application directory.
// GET /style.css etc
app.use(express.static(__dirname + '/public'));
// Mount the middleware at "/static" to serve static content only when their request path is prefixed with "/static".
// GET /static/style.css etc.
app.use('/static', express.static(__dirname + '/public'));

TA貢獻(xiàn)1874條經(jīng)驗(yàn) 獲得超12個(gè)贊
default.css 應(yīng)該在 http://localhost:3001/default.css
在styles中app.use(express.static(__dirname + '/styles'));只是告訴快遞在尋找styles目錄靜態(tài)文件服務(wù)。它不會(huì)(令人困惑地)形成可用路徑的一部分。
- 3 回答
- 0 關(guān)注
- 1373 瀏覽
添加回答
舉報(bào)