...

//
index page var items=[{title:"文章1"},{title:"文章2"}]; app.get('/',function(req,res){ res.render('index',{title:'电影首页',items:items}); });

...

对应ejs

<html>
<head>
<title>my ejs template</title>
</head>

<body>
    <p>Hi <%= title %></p>
    <p>文章列表</p>
    <ul>
        <% items.forEach(function(item){%>
                <li><%=item.title %></li>
            <% }) %>
    </ul>
</body>
</html>

预览图

ejs循环实例

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-05-17
  • 2021-07-11
  • 2021-12-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-12-15
  • 2021-12-15
相关资源
相似解决方案