编译ejs时获取括号
Getting brackets when compiling ejs
我的节点js文件
app.get("/", async(req, res) => {
const shortUrls = await ShortUrl.find();
const url = await ShortUrl.find({
realEmail: email
});
res.render("index", {
shortUrls: shortUrls,
url: url,
userEmail: profile._json.email,
userName: profile.displayName,
id: profile.id,
async: true
});
});
我的代码如下:
<tbody>
<%url.forEach((shortUrl) => { %>
<tr>
<td>
<a href="<%= shortUrl.full %>">
<%= shortUrl.full %>
</a>
</td>
<td>
<a href="<%= shortUrl.short %>">localhost:3000/<%= shortUrl.short %></a>
</td>
<td>
<%= shortUrl.clicks %>
</td>
<td>
<%= shortUrl.GivenEmail %>
</tr>
<%})%>
</tbody>
当我 运行 这样做时,我在我的网站上得到了以下信息。
有谁知道为什么会这样?请帮忙。
只需从 app.js
中删除 async 属性 即可
我的节点js文件
app.get("/", async(req, res) => {
const shortUrls = await ShortUrl.find();
const url = await ShortUrl.find({
realEmail: email
});
res.render("index", {
shortUrls: shortUrls,
url: url,
userEmail: profile._json.email,
userName: profile.displayName,
id: profile.id,
async: true
});
});
我的代码如下:
<tbody>
<%url.forEach((shortUrl) => { %>
<tr>
<td>
<a href="<%= shortUrl.full %>">
<%= shortUrl.full %>
</a>
</td>
<td>
<a href="<%= shortUrl.short %>">localhost:3000/<%= shortUrl.short %></a>
</td>
<td>
<%= shortUrl.clicks %>
</td>
<td>
<%= shortUrl.GivenEmail %>
</tr>
<%})%>
</tbody>
当我 运行 这样做时,我在我的网站上得到了以下信息。
有谁知道为什么会这样?请帮忙。
只需从 app.js
中删除 async 属性 即可