我想将数组传递给哈巴狗视图,并通过对其进行迭代来构造视图,但是在加载视图时出现错误。
PUG视图
include includes/header.pug
body.index
include includes/nav-bis.pug
.hero
.hero-body
.container
.box
for post in posts
h1= posts[post].title
p= posts[post].content.substring(0, 100)+" ..."
a(href="/posts/" + posts[post].title) Read More
app.js
app.get('/blog', function(req, res) {
console.log(posts);
res.render('blog', {posts: posts});
});
你以错误的方式致电该职位。试试下面的代码:
h1= post.title
是的,我现在想通了!我要休息一下