生成 td 元素时下划线.js 错误

发布于 2024-12-23 14:46:14 字数 537 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿! 2024-12-30 14:46:14

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文