3 回答

TA貢獻1820條經驗 獲得超2個贊
嘗試http://localhost:3001/default.css。
要/styles在您的請求URL中使用:
app.use("/styles", express.static(__dirname + '/styles'));
查看此頁面上的示例:
//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貢獻1874條經驗 獲得超12個贊
default.css 應該在 http://localhost:3001/default.css
在styles中app.use(express.static(__dirname + '/styles'));只是告訴快遞在尋找styles目錄靜態文件服務。它不會(令人困惑地)形成可用路徑的一部分。
- 3 回答
- 0 關注
- 1369 瀏覽
添加回答
舉報