gpt4 book ai didi

javascript - 下划线模板问题 - Uncaught SyntaxError : Unexpected token <

转载 作者:行者123 更新时间:2023-11-30 12:57:37 25 4
gpt4 key购买 nike

当我尝试加载我的下划线模板之一时出现上述错误。我猜它是 for 循环中的某种问题(可能应该是一个 -.each 但我还不太了解它们的结构)。

我的模板

    <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>

它被下面的调用了

$('#tableDiv').html(_.template($("#Customer-List-View").html(), {'customers': globalCustomerList}));

我确定它确实很简单,但它是我模板中的第一个表,我看不出问题所在。

收到的任何帮助

最佳答案

您在 for 中使用逗号而不是分号。

<% for (var i = 0, i < customers.length, i++){ %>

应该是

<% for (var i = 0; i < customers.length; i++){ %>

关于javascript - 下划线模板问题 - Uncaught SyntaxError : Unexpected token <,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18490733/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com