对于每个循环,用EJS模板

发布于 2025-02-14 01:38:35 字数 520 浏览 0 评论 0原文

我试图执行以下代码行,并最终得到以下错误消息。是否有任何代码建议可以清除此问题?

<%= kindOfItems.forEach( function (item) { %>
        <div class = "item">
            <input type="checkbox">
            <p>
            <%= item.name %>
            </p>
        </div>
     <%=  }) %>  

syntaxerror:d:\ web开发\ todolist \ todo-list ---- ejs-master \ todo-list --- ejs-aster \ ejs-master \ views \ views \ list.ejs

syntaxerror:意外令牌')' >

I tried to execute the below lines of code and ended up with the below error message. Any code suggestions to clear this out?

<%= kindOfItems.forEach( function (item) { %>
        <div class = "item">
            <input type="checkbox">
            <p>
            <%= item.name %>
            </p>
        </div>
     <%=  }) %>  

SyntaxError: Unexpected token ')' in D:\web development\todoList\Todo-List---EJS-master\Todo-List---EJS-master\views\list.ejs while compiling ejs

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

万人眼中万个我 2025-02-21 01:38:36

不熟悉EJ,而是通过它的外观,您缺少返回语句。快速Google之后,您似乎需要做以下操作

<%= kindOfItems.map( function (item) { %>
        return <div class = "item">
            <input type="checkbox" />
            <p>
            <%= item.name %>
            </p>
        </div>
<%=  }) %>  

Not familiar with ejs but by the looks of it you are missing a return statement. After a quick google it seems you need to do the following

<%= kindOfItems.map( function (item) { %>
        return <div class = "item">
            <input type="checkbox" />
            <p>
            <%= item.name %>
            </p>
        </div>
<%=  }) %>  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文