我是Ember.js的新手,我想做一个简单的格子表格。我使用的是Bootstrap 4、ember-composable-helpers和Handlebar。我想知道有没有人不用javascript就能做到这一点?
我的样机代码如下所示,但是我不知道如何在#if HBS helper中插入逻辑:
<h1>Table</h1>
<table class="w-100">
{{#each (range 0 5) as |row|}}
<tr class="">
{{#each (range 0 5) as |cell|}}
{{!-- HOW DO I GIVE A TRUTHY VALUE FOR CELL == 1??? --}}
{{#if cell == 1 }}
<td class="bg-dark">{{cell}}</td>
{{/if }}
{{/each}}
</tr>
{{/each}}
</table>我应该只做一个三元类吗?我该怎么做呢?
发布于 2019-11-14 09:19:31
既然您不想编写任何JavaScript,我认为您的主要选择就是安装和使用ember-truth-helpers
ember install ember-truth-helpers<h1>Table</h1>
<table class="w-100">
{{#each (range 0 5) as |row|}}
<tr class="">
{{#each (range 0 5) as |cell|}}
{{!-- HOW DO I GIVE A TRUTHY VALUE FOR CELL == 1??? --}}
{{#if (eq cell 1) }}
<td class="bg-dark">{{cell}}</td>
{{/if }}
{{/each}}
</tr>
{{/each}}
</table>如果你在学习Ember Discord的过程中有任何一般性的问题,我建议你加入Ember。祝好运!
https://stackoverflow.com/questions/58827155
复制相似问题