我有以下代码:
<div class="form-group {{#if afFieldIsInvalid name='latitude' OR name='longitude'}}has-error{{/if}}">......</div>
如何在空格键模板的 if 条件中使用 AND/OR ?
最佳答案
空格键无法处理逻辑表达式,因此您需要创建一个帮助程序来处理计算。
其实你可以实现and
具有嵌套 if 的功能,如下所示:
{{#if condition1}}
{{#if condition2}}
<p>Both condition hold!</p>
{{/if}}
{{/if}}
和
or
像这样:{{#if condition1}}
<p>One of the conditions are true!</p>
{{else}}
{{#if condition2}}
<p>One of the conditions are true!</p>
{{/if}}
{{/if}}
但我更喜欢使用助手。
关于meteor - 空格键:如何使用和/或在 if 语句中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28426843/