我该如何解决这个问题?
<%= if(comments.length) { %>
<%=_.each(comments, function (comment) {%>
<div><%=comment.message%></div>
<%=});%>
<%=}%>
我可以在PHP中执行以下操作:
<?php if(count($comments) { ?>
<?php foreach ($comments as $comment){ ?>
<div><?=$comment->message?></div>
<?php } ?>
<?php } ?>
谢谢
答案 0 :(得分:2)
也许这就是你要找的......
从=
<%=
<% if(comments.length) { %>
<% _.each(comments, function (comment) {%>
<div><%=comment.message%></div>
<% }); %>
<% } %>
答案 1 :(得分:2)
<% if(comments.length) {
_.each(comments, function (comment) { %>
<div><%=comment.message%></div>
<% });
} %>