简体   繁体   English

如何在Meteor.js中使用Blaze构建网格?

[英]How to build a grid with Blaze in Meteor.js?

I have a collection of items, that I would like to stuff into a bootstrap grid. 我有一个项目集合,我想填入引导网格。 This then looks like this: 这看起来像这样:

 <div class="row">
  <div class="col-md-8">.col-md-8</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
 <div class="col-md-8">.col-md-8</div>
 <div class="col-md-4">.col-md-4</div>
</div>

So I would need to loop through my collection and adding after every second item 所以我需要遍历我的集合并在每秒后添加

There are two issues: 有两个问题:

  • invalid html! 无效的HTML! No idea how to get around this 不知道如何解决这个问题
  • Issues with the module, but I think with some helpers I could get around. 该模块的问题,但我认为我可以解决一些帮助。

Best would be if there were some examples. 如果有一些例子,那将是最好的。

Thanks for any inputs 谢谢你的任何投入

check out this question. 看看这个问题。 you should be searching for handlebars or spacebars to get better results. 你应该搜索把手或空格键以获得更好的结果。 Blaze is the template engine; Blaze是模板引擎; not the template system (if that makes sense.) 不是模板系统(如果有意义的话。)

How do I populate a bootstrap grid system using handlebars for each command in Meteor.js? 如何使用Meleb.js中每个命令的把手填充引导网格系统?

Generically, you need to ensure that your collection is exposed to the template, most likely in a template helper. 通常,您需要确保将集合公开给模板,最有可能是模板助手。 Then you can iterate the collection items like so: 然后你可以像这样迭代集合项:

{{#each templateHelperName}}
<div class="row">
  <div class="col-md-8">{{propertyName1}}</div>
  <div class="col-md-4">{{propertyName1}}</div>
</div>
{{/each}} 

To create a template helper, take a look at the meteor docs; 要创建模板助手,请查看流星文档; they're quite good. 他们很好。

If this doesn't help, perhaps you can provide some more clarity about what your collection looks like, and how you'd like it displayed. 如果这没有帮助,也许您可​​以更清楚地了解您的集合的外观以及您希望如何显示它。 Your code doesn't really give much indication. 你的代码并没有给出太多指示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM