问题
How can i write or condition in ejs template.I tired the following
<%if (user ===0 || user ===1) { %>
<div id="main_div">
My content over here
</div>
<% } %>
it will satisfy the first condition but not the second one.
回答1:
if you use the strong equality (=== instead of ==) ensure that your variable contains integer.
"1" == 1 // true
"1" === 1 // false
Or use parseInt around your variable
<%if (parseInt(user) ===0 || parseInt(user) ===1) { %>
来源:https://stackoverflow.com/questions/48168887/how-to-write-or-condition-in-ejs