无法将数据从我的 nodejs(在使用 select * 在 mysql 上查询后)呈现到 ejs 页面

Unable to render data from my nodejs(after using select * query on mysql) to ejs page

我从 mysql 数据库中获取了结果,并且在我的控制台中获取了数据,但它不会在我的 ejs 页面中呈现。 这是我的 .ejs 页面代码:

<table>
<tr>
  <th>Name</th>
  <th>Date Formed</th>
  <th>Location</th>
</tr>

<%for(int i = 0;i < Allo.length; i++){%>
        <tr>
          <td><%=Allo.name%></td>
          <td><%=Allo.form_date%></td>
          <td><%=Allo.location%></td>
        </tr>
<%}%>

</table>

这是我的 app.js:


    app.get("/Teams",function(req,res){
      db.query('SELECT * FROM team',function(err,result){
        console.log(result);
        res.render("Teams",{Foo:"",Allo:result});
    
      });
    
    });

console.log(结果)工作正常。

伙计们,我明白了。使用 forEach 解决了问题。

<% Allo.forEach(function(Allo){ %>
          <tr>
            <td><%=Allo.name%></td>
            <td><%=Allo.form_date%></td>
            <td><%=Allo.location%></td>
          </tr>
  <% })%>