[英]How can I put the next values in my #each in handlebars into the next line?
i am having trouble using {{#each}} helper for array, as what i have seen in different tutorials when you have an array like this: (this is the array values im trying to output, this is from my main.js)我在为数组使用 {{#each}} 助手时遇到问题,正如我在不同教程中看到的,当你有这样的数组时:(这是我试图输出的数组值,这是来自我的 main.js)
res.render('contact', {
people: [
"james",
"peter",
"sandrack",
"morissa"
]
and this is my contact.handlebars:这是我的contact.handlebars:
{{#each people}}
<p> {{this}}</p>
{{/each}}
from the tutorials, the output must be that the names are in different lines like this: james peter sandrack morissa从教程中,输出必须是名称在不同的行中,如下所示: james peter sandrack morissa
but instead my output is only in one line and also without space:但相反,我的输出仅在一行中并且也没有空格:
can anyone please help me solve my problem, it will be a big help for me thank you so much任何人都可以帮我解决我的问题,这对我有很大的帮助,非常感谢
I don't know what you are doing wrong, but, It is something you didn't send in your question...我不知道你做错了什么,但是,这是你没有在问题中发送的东西......
Check every tag and "(" or "{" in your script.检查脚本中的每个标签和“(”或“{”。
It works.有用。
module.exports.test = (req,res,next) => {
res.render('test', {
people: [
"james",
"peter",
"sandrack",
"morissa"
]})
}
View:看法:
{{#each people}}
<p>{{this}}</p>
{{/each}}
Even, for clearly understand how it works, you can use:甚至,为了清楚地了解它是如何工作的,您可以使用:
{{#each people as |name|}}
<p>{{name}}</p>
{{/each}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.