How can I use if statement in ejs?

前端 未结 3 1640
没有蜡笔的小新
没有蜡笔的小新 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:25

    The shorthand version is correct, but it does have a syntax error

    <%= role === 'admin' ? 'Super Admin' : 'Admin' %>
    

    Or

    <% if(role === 'admin'){ %>
        

    Super Admin

    <% } else{ %>

    Admin

    <% } %>

提交回复
热议问题