我的目标是将MySQL查询中的数据放入HTML表格中。但是,我有以下输出:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
来自这个简单的ejs
文件:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table>
<% data.forEach(function(ind){ %>
<li><%= data %></li>
<% }) %>
</table>
</body>
</html>
从
获取数据 pool.query(query, function select(error, results, fields) {
var temp = "";
if (error) {
console.log(error);
pool.end();
}
res.render('index.html',{data:results, error:null});
//pool.end();
});
我不知道我的代码中有什么内容。有什么建议吗?
答案 0 :(得分:0)
这样做:
<% data.forEach(function(ind){ %>
<li><%= JSON.stringify(ind) %></li>
<% }) %>