作者:Boss-201411 | 来源:互联网 | 2023-09-15 13:43
usingthe express.static middlewareinanExpressapp.Servestaticcontentfortheappfromthe“public
using the express.static middleware in an Express app.
Serve static content for the app from the “public” directory in the application directory:
index.js
// GET /style.css etc
app.use(express.static(path.join(__dirname, 'public')))
在工程目录下新建一个public文件夹,该文件夹下放static contents, like app.css, app.js, etc.
app.css
body{
background-color: pink;
}
在对应的ejs文件下添加依赖: