Aurelia @儿童装饰师不在奥雷利亚为我工作

Aurelia @儿童装饰师不在奥雷利亚为我工作,aurelia,Aurelia,我试图使用aurelia@children装饰器在父容器视图模型中拥有所有子元素按钮,但这似乎不起作用。有人举过一个例子来说明@children装饰器是如何工作的吗 我想做的是有一个父容器元素,它有一堆子元素(按钮),在父容器中,我试图通过引用父容器中的所有按钮来跟踪单击了哪些按钮,因此每当用户单击按钮时,我可以反复浏览按钮列表,查看以前已经单击过哪些按钮 目前,我在页面下方的代码无法加载 es6.promise.js:116未处理的承诺拒绝类型错误: 评出 @儿童(“按钮”)按钮 行允许页面正

我试图使用aurelia@children装饰器在父容器视图模型中拥有所有子元素按钮,但这似乎不起作用。有人举过一个例子来说明@children装饰器是如何工作的吗

我想做的是有一个父容器元素,它有一堆子元素(按钮),在父容器中,我试图通过引用父容器中的所有按钮来跟踪单击了哪些按钮,因此每当用户单击按钮时,我可以反复浏览按钮列表,查看以前已经单击过哪些按钮

目前,我在页面下方的代码无法加载 es6.promise.js:116未处理的承诺拒绝类型错误:

评出

@儿童(“按钮”)按钮

行允许页面正常加载。谢谢你的关注

app.html

<template>
  <require from="./custom-element"></require>
  <my-custom-element>
      <button class="btn btn-default" type="button">On</button>
      <div>
        This div falls back to &lt;content&gt; since nothing more specific chooses it. <br />
        Notice how it is displayed last b/c of this.<br />
        Remove &lt;content /&gt; element in custom element and this won't be used in the rendering of the custom element.
      </div>
      <div class="footer">Footer</div>
      <button class="btn btn-default" type="button">Off</button>
  </my-custom-element>      
</template>

下面是我在sync和children示例中发现的内容

@customElement('my-custom-element')
@children({ name: "buttons", selector: "button" })
export class MyCustomElement {
  bind() {
    console.log(this.buttons);
  }
}
在尝试遍历子元素以查找元素时,还存在一个问题

import {customElement, children} from 'aurelia-framework';

@customElement('my-custom-element')
export class MyCustomElement {
  @children('button') buttons;
  constructor() {
  }

  bind() {
    console.log(this.buttons);
  }
}
@customElement('my-custom-element')
@children({ name: "buttons", selector: "button" })
export class MyCustomElement {
  bind() {
    console.log(this.buttons);
  }
}