我有以下underscore.js模板。我想检查一个数组值是否等于pubHols数组中的日期。这是什么语法?
var pubHols = [
{ date: '2015-12-25', title: 'Christmas Day' },
{ date: '2015-12-28', title: 'Boxing Day' },
];
<% _.each(days, function(day) { %>
<% if(day.date == pubHols.date){ %>
<div class="pubHol"><span class="day-number"><%= day.day %></span></div>
<% } %>
<% }); %>
答案 0 :(得分:0)
您可以使用findWhere
<% if(_.findWhere(pubHols, { date: day.date })){ %>