【发布时间】:2020-11-28 01:29:18
【问题描述】:
我想将一个数组传递给一个 pug 视图并通过迭代它来构造视图,但是当我加载视图时出现错误。
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});
});
【问题讨论】: