How can I include css files using node, express, and ejs?

前端 未结 11 852
执念已碎
执念已碎 2020-12-01 01:37

I\'m trying to follow the instructions to https://stackoverflow.com/a/18633827/2063561, but I still can\'t get my styles.css to load.

From app.js

ap         


        
11条回答
  •  一个人的身影
    2020-12-01 02:20

    I have used the following steps to resolve this problem

    1. create new folder (static) and move all js and css file into this folder.
    2. then add app.use('/static', express.static('static'))
    3. add css like < link rel="stylesheet" type="text/css" href="/static/style.css"/>
    4. restart server to view impact after changes.

提交回复
热议问题