这是我的代码:-
app.get("/articles", function(req, res) {
const art=[]
let today=Articles.find(function(err,articles){
articles.forEach(function(ar){
art.push({
posttitle: ar.title,
posttext: ar.text
});
});
res.render("articles.ejs", {
article:art,
userStatus:"SignUp",
jq:$
});
})
});
这是我的ejs代码:-
<%- include("header.ejs") %>
<% article.forEach(function(post){ %>
<h1><%= post.posttitle %></h1>
<% let text = post.posttext; %>
<p style="display:inline;"><%= text %></p> <a href="/posts/<%=post.posttitle %>"> Read More</a>
<% }); %>
<%- include("footer.ejs") %>
如何获取文章内容,以HTML形式显示,当前,如果转到此页面,我将获得字符串形式的文章内容(例如:如果post.posttext =“ 嗨”,我得到的是嗨而不是“ hi”。
我如何使其按预期工作?