cats.ejs
<body> <h1>My baby cats</h1> <%for(let cat of cats){%> <li> <%=cat%> </li> <%}%> </body>
app.get(‘/cats‘, (req, res) => { const cats = [‘sweety‘, ‘candy‘, ‘cutey‘, ‘honey‘]; res.render(‘cats.ejs‘, { cats }) })
原文:https://www.cnblogs.com/LilyLiya/p/14365339.html