This is the problematic part:
<% for(var j = 0;j < <%= items %>.length; j++){ %>
<li><%= items[j] %></li>
<%}%>
It's really hard to tell what you are trying to do here, but the root cause is that you cannot nest sets of <%... %>
.
Probably you just want:
<% for (var j=0; j < items.length; j++) { %>
<li><%= items[j] %></li>
<% } %>
Possibly you expect items
to be provided by client-side JavaScript and not EJS, in which case see What is the difference between client-side and server-side programming?
Please correct your code as below, you don't need to use the <%= %>
with items.
<% for(var j = 0;j < items.length; j++){ %>
<li><%= items[j] %></li>
<%}%>
I think the reason for this could be that you have inserted the "<%" tag inside another one.
Can you please try to rewrite the code like this?
<% for(var j = 0;j < items.length; j++){ %>
<li><%= items[j] %></li>
<%}%>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.