空集合上的 EJS 循环仍在评估?
EJS loop on null collection still evaluates?
我正在尝试在 EJS 中执行一个简单的操作,如果集合存在则对集合执行 for 循环。
<% if(typeof applicant.customerContacts != 'undefined'
&& applicant.customerContacts) { %>
<% applicant.customerContacts.forEach(function(contact) { %>
<div>
//stuff goes here
</div>
<% } %>
<% } %>
但是我在运行时不断收到此错误:
[SyntaxError: missing ) after argument list in {redacted}/applicantOverview.ejs while compiling ejs]
如果数据可能来自对象 null/missing,我该如何编写循环来处理?
我是个白痴
我在 foreach 调用中缺少右括号。
继续前进....
我正在尝试在 EJS 中执行一个简单的操作,如果集合存在则对集合执行 for 循环。
<% if(typeof applicant.customerContacts != 'undefined'
&& applicant.customerContacts) { %>
<% applicant.customerContacts.forEach(function(contact) { %>
<div>
//stuff goes here
</div>
<% } %>
<% } %>
但是我在运行时不断收到此错误:
[SyntaxError: missing ) after argument list in {redacted}/applicantOverview.ejs while compiling ejs]
如果数据可能来自对象 null/missing,我该如何编写循环来处理?
我是个白痴
我在 foreach 调用中缺少右括号。
继续前进....