【发布时间】:2021-09-04 22:04:18
【问题描述】:
我是编码新手,在某个地方卡住了,因为我需要一些帮助。我有一个带有a、h2 和div 标签的基本玉石模板
h2
a(href='/'+ '#{postId}') #{title}
.content #{contentText}
在这里我找到第一个 title、text 和 postId 并将其发送到我的玉模板
router.get('/', function(req, res, next) {
const findPost = postInfo.find({}).then((data) => {
posts.push(...data);
res.render('index' , {
title: posts[0].title,
contentText: posts[0].content,
postId: posts[0].postId
});
});
});
现在我需要创建相同的哈巴狗元素,但值必须来自posts[1] 数组,然后再次创建哈巴狗,现在值来自posts[2]。我必须多次这样做,但不知道如何。谁能给我小费?
【问题讨论】:
-
阅读pugjs.org/language/iteration.html。 (同时查看其余文档,您可能会遗漏其他重要内容)