How can I use if statement in ejs?

前端 未结 3 1643
没有蜡笔的小新
没有蜡笔的小新 2021-02-07 14:17

I have a page that makes a foreach and show some photos like this

<% imgs.forEach(function(img) { %>
      /s         


        
3条回答
  •  醉酒成梦
    2021-02-07 14:32

    Something like this:

    <% if(imgs.length > 0){ %>
        <% imgs.forEach(function(img) { %>
            
        <% }); %>
    <% } else{ %>  
        

    no photos uploaded

    <% } %>

    Reference

提交回复
热议问题