生成 td 元素时下划线.js 错误
Underscore 在生成 html td
标记时似乎确实存在问题。
以下代码有效:
<% _.each(table_heads, function(head, index) { %>
<li><%= head %></li>
<% }); %>
这不起作用(原因: 标记生成):
<% _.each(table_heads, function(head, index) { %>
<td><%= head %></td>
<% }); %>
控制台消息:head is not Defined
。
我还将插值的模板设置更改为以下内容:
interpolate:/\{\{(.+?)\}\}/g,
但上面的错误消息保持不变。
Underscore does seem to have a problem with generating html td
tags.
The following code works:
<% _.each(table_heads, function(head, index) { %>
<li><%= head %></li>
<% }); %>
This does not work (cause: <td>
tag production):
<% _.each(table_heads, function(head, index) { %>
<td><%= head %></td>
<% }); %>
Console message: head is not defined
.
I also changed the template settings for interpolate to the following:
interpolate:/\{\{(.+?)\}\}/g,
But the error message from above stays the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
head is not Defined 清楚地表明 json 数组中的 1 个元素缺少“head”属性。
您可以添加要传递给模板的 json 吗?
head is not defined clearly shows 1 of your elements in the json array is missing the 'head' attribute.
could you perhaps add the json that you are passing to the template.