小编Mis*_*sha的帖子

如何使用Meteor Spacebars {{#each}}块迭代一系列字符串?

我有一个Mongo.Collection,它包含'Question'对象.每个'问题'都有一个叫做的属性choices

Questions.insert({
    text: 'What is the capitol of the US?',
    choices: [
    "Washington D.C.",
    "Houston",
    "New York City",
    "Los Angeles"
    ],
    correctChoice: 0,
    date: new Date().toDateString()
});
Run Code Online (Sandbox Code Playgroud)

在我的模板中,我有这个:

<div class="question">
    <div class="question-content">
        <p>{{text}}</p>
        <ul>
            {{#each choices}}
            //?????????
            {{/each}}
        </ul>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

为了使包含适当选择的列表项的无序列表更受欢迎,我应该放置什么而不是问号?

谢谢你的阅读.对不起,如果这很容易.我在Meteor还是一个小小的菜鸟.=)

javascript arrays meteor spacebars

1
推荐指数
1
解决办法
836
查看次数

标签 统计

arrays ×1

javascript ×1

meteor ×1

spacebars ×1