【问题标题】:Binding 2 values in Aurelia在 Aurelia 中绑定 2 个值
【发布时间】:2016-08-23 07:17:16
【问题描述】:

我是 Aurelia 的新手,在值绑定中遇到这个问题,我不明白为什么它不起作用。

所以我有一个父组件,这是它使用子组件的 html 的一部分:

 <div repeat.for="testWebsite of testWebsites" class="tab-pane ${$index==0? 'active' : ''}" id="${testWebsite.website_id}" role="tabpanel">
            <test-website showSummaryBar.bind="testWebsites.length > 1" payload.bind="testWebsite"></test-website>
        </div>

test-website 是子组件。在其代码中,我声明了 2 个可绑定变量,如下所示:

export class TestWebsiteCustomElement {
@bindable payload;
@bindable showSummaryBar;
.....

payload 已成功绑定到父级设置的 testWebsite。但是 showSummaryBar 始终为空。我错过了什么吗?提前致谢。

【问题讨论】:

    标签: aurelia


    【解决方案1】:

    可绑定属性从 VM 中的 camelCase 转换为 View 中的 dash-case(也称为“kebab case”)。所以showSummaryBar变成show-summary-bar

    <test-website show-summary-bar.bind="testWebsites.length > 1" 
                  payload.bind="testWebsite"></test-website>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-31
      • 2016-12-18
      • 2020-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多