gpt4 book ai didi

node.js - 语法错误 : Unexpected token ')' in ejs file

转载 作者:行者123 更新时间:2023-12-03 22:32:47 25 4
gpt4 key购买 nike

<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8">
<title>List Page</title>
</head>

<body>
<h1>List Page</h1>
<a href="/insert">INSERT DATA</a>
<hr/>
<table width = "100%" border="1">
<tr>
<td>DELETE</td>
<td>EDIT</td>
<td>ID</td>
<td>Name</td>
<td>Model Number</td>
<td>Series</td>
</tr>

<%= data.forEach((item, index) => { %>
<tr>
<td><a href="/delete/<%= item.id %>">DELETE</a></td>
<td><a href="/edit/<%= item.id %>">EDIT</a></td>
<td><%= item.id %></td>
<td><%= item.name %></td>
<td><%= item.modelnumber %></td>
<td><%= item.series %></td>
</tr>
<%= }) %>

</table>
</body>
</html>

I'm currently having a small problem with syntaxError. I checked asfar as i can but i failed. Can you tell me is there some miss typo inthere?

I wanna show this to website but it doesn't give me a hint.. I reallyhave no clue of where is wrong.. Please help me..

最佳答案

欢迎来到 SO,您需要放置 data.foreach() 没有这个 ejs 标签 <%= 但这个 ejs 标签 <% 。所以你的代码应该是这样的:

<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8">
<title>List Page</title>
</head>

<body>
<h1>List Page</h1>
<a href="/insert">INSERT DATA</a>
<hr/>
<table width = "100%" border="1">
<tr>
<td>DELETE</td>
<td>EDIT</td>
<td>ID</td>
<td>Name</td>
<td>Model Number</td>
<td>Series</td>
</tr>
<!-- Here is the first change -->
<% data.forEach((item, index) => { %>
<tr>
<td><a href="/delete/<%= item.id %>">DELETE</a></td>
<td><a href="/edit/<%= item.id %>">EDIT</a></td>
<td><%= item.id %></td>
<td><%= item.name %></td>
<td><%= item.modelnumber %></td>
<td><%= item.series %></td>
</tr>
<!-- Here is the second change -->
<% }) %>

</table>
</body>
</html>

关于node.js - 语法错误 : Unexpected token ')' in ejs file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65266622/

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