如何IF
在 jQuery 模板中使用语句?
这是我的模板:
<script type="text/html" id="attachmentListTemplate">
{{if $item.current_cmt_id == id }}
<li>
<a href="${link}" class="fancyIFrame clearfix">${title}</a>
</li>
{{/if}}
</script>
其中 id 本质上${id}
是由数据绑定传递的(通过 KnockoutJS)。没有 IF 语句的输出很好,如下所示:${$item.current_cmt_id}
这是数据绑定(由 KnockoutJS 提供支持):
<ul data-bind='template: { name: "attachmentListTemplate", foreach: attachmentsModel.convAttachments, templateOptions: {current_cmt_id: <%=comment.id%>} }'> </ul>
关于为什么 if 语句不起作用的任何建议?我是否正确比较了这两种情况?