Aurelia 将数组从父模板传递到子模板 处境

Aurelia 将数组从父模板传递到子模板 处境,aurelia,Aurelia,我们已经能够将一个数组从父屏幕传递到模板。customAttribute有效,但historyItems无效 parent-template.html <template> <require from="./child-template"></require> <child-template historyItems.bind="history[0].HistoryItems" custom-a

我们已经能够将一个数组从父屏幕传递到模板。
customAttribute
有效,但
historyItems
无效

parent-template.html

<template>

    <require from="./child-template"></require>

    <child-template

         historyItems.bind="history[0].HistoryItems" 
         custom-attribute.bind="history[0].HistoryItems.length">

    </child-template>

</template>
<template>

    ${customAttribute} 
    ${historyItems.length} 
    ${historyItems}

    <p repeat.for="item of historyItems">
        Foobar
    </p>

</template>
问题:
如何传递
historyItems
数组?

您必须使用
历史项目。bind=“history[0]。historyItems”

按照惯例,Aurelia将具有混合大小写的自定义元素名称和可绑定属性名称连字符。这是因为HTML不区分大小写,所以像
historyItems.bind
这样的表达式与
historyItems.bind
没有什么不同。但是,这对于区分大小写的JavaScript无效。看

简而言之,对于大小写混合的属性,必须使用连字符拆分单词:

@bindable historyItems; <-- js file
history-items.bind="something"; <-- html file
repeat.for="item of historyItems" //<-- here you should not use hyphen because it is not an html expression
@bindable历史项目;
@bindable historyItems; <-- js file
history-items.bind="something"; <-- html file
repeat.for="item of historyItems" //<-- here you should not use hyphen because it is not an html expression