How to Handle Global Data in ExpressJS

前端 未结 5 1340
深忆病人
深忆病人 2021-01-21 19:22

I am trying to build an express.js app and I want to pass some data to my main layout. For example, a list of navigation links that I use on every page. I know how to pass data

5条回答
  •  悲&欢浪女
    2021-01-21 19:48

    Here you can include file of header & footer inside your each ejs file

    <%- include('/header.ejs') %>
    <%- include('/footer.ejs') %>
    

    This is for ejs view engine

    app.set("view engine", "ejs");
    

提交回复
热议问题