2011-09-01 55 views

回答

1

您可以使用下劃線_.keys()功能

temp = "<% _.each(_.keys(data), function(name){ %> 
     <div>Hello, showing content of '<%= name %>'</div> 
     <% }); %>" 
_.template(temp, data); // <div>Hello, showing content of 'showname-array'</div> 
         // <div>Hello, showing content of 'andanotherName-array'</div>