ember.js 声明发布时的手柄

hjqgdpho  于 2022-11-23  发布在  其他
关注(0)|答案(1)|浏览(123)
{{#each this.data.roles as |role|}}
          {{#if (eq role.name ( 'moderator' 'organizer'))}}
            <div class="item">
              {{role.name}}
            </div>
          {{/if}}
      {{/each}}

只给主持人发div,不给组织者发

ncecgwcz

ncecgwcz1#

欢迎来到Stack Overflow。你的helper调用需要稍微调整一下。我假设你需要同时显示版主和组织者角色的div。所以,条件(在js中)应该是这样的,
role === "moderator" || role === "organizer"
eqor帮助器的帮助下,可以将其转换为handler表达式,例如:

{{#each this.data.roles as |role|}}
  {{#if (or (eq role.name "moderator") (eq role.name "organizer"))}}
    <div class="item">
      {{role.name}}
    </div>
  {{/if}}
{{/each}}

相关问题