Javascript 下划线模板问题-未捕获语法错误:意外标记<;
当我尝试加载一个下划线模板时,出现上述错误。我猜它是for循环中的某种问题(可能是一个-,但我还不太了解它们的结构) 我的模板Javascript 下划线模板问题-未捕获语法错误:意外标记<;,javascript,underscore.js,Javascript,Underscore.js,当我尝试加载一个下划线模板时,出现上述错误。我猜它是for循环中的某种问题(可能是一个-,但我还不太了解它们的结构) 我的模板 <script type="text/html" id="Customer-List-View"> <p> Please click on a customer to select </p> <table > <thead>
<script type="text/html" id="Customer-List-View">
<p> Please click on a customer to select </p>
<table >
<thead>
<th> Customer Name </th><th>Last Invoice date</th><th>Last item added</th>
</thead>
<tbody>
<% for (var i = 0, i < customers.length, i++){ %>
<tr class="cusTableRow" id="<%=customers[i].objectId %>" >
<td> <%= customers[i].custName %> </td>
<td> <%= customers[i].custLastInvoiceDate %> </td>
<td> <%= customers[i].CustLastItemDate %> </td>
</tr>
<% }; %>
</tbody>
</table>
<button id="customerAdd"> Add a new customer </button>
<p> here should be a set of buttons for working with customers </p>
</script>
我相信这很简单,但这是我在模板中的第一个表,我看不出问题所在
收到的任何帮助您在的
中使用逗号而不是分号
<% for (var i = 0, i < customers.length, i++){ %>
应该是
<% for (var i = 0; i < customers.length; i++){ %>
或者您可以使用u.each()代替标题。我查看了每个标题,但不确定上下文设置。我计划在这一页开始工作后再看一遍。谢谢你的建议
<% for (var i = 0; i < customers.length; i++){ %>