【发布时间】:2016-07-09 05:12:56
【问题描述】:
我正在尝试 EJS 中的简单操作,如果集合存在,则在集合上执行 for 循环。
<% if(typeof applicant.customerContacts != 'undefined'
&& applicant.customerContacts) { %>
<% applicant.customerContacts.forEach(function(contact) { %>
<div>
//stuff goes here
</div>
<% } %>
<% } %>
但是我在运行时不断收到此错误:
[编译 ejs 时在 {redacted}/applicantOverview.ejs 中的参数列表之后的 SyntaxError: missing )]
如果对象中的数据可能为空/缺失,我该如何编写循环来处理?
【问题讨论】: