Aurelia @bindable的操作顺序

Aurelia @bindable的操作顺序,aurelia,Aurelia,如果我的子控件(本例中为孙子控件)如下所示: <my-control region-id.two-way="location.regionId"></my-control> 我希望regionId在附件发生之前为1。这是预期的行为吗?应在bind()阶段填写变量 如果将日志记录添加到每个阶段: export class Child { @bindable() public field: string; constructor() { console

如果我的子控件(本例中为孙子控件)如下所示:

<my-control region-id.two-way="location.regionId"></my-control>

我希望
regionId
附件发生之前为1。这是预期的行为吗?

应在
bind()
阶段填写变量

如果将日志记录添加到每个阶段:

export class Child {
  @bindable()
  public field: string;

  constructor() {
    console.info("constructor: ", this.field);
  }

  bind() {
    console.info("bind: ", this.field);
  }

  attached() {
    console.info("attached: ", this.field);
  }
}
它生成以下日志输出:

constructor:  undefined
bind:  test
attached:  test

其中
test
是我将其绑定到的值。

我认为父视图模型中的问题,其中
location.regionId
在执行子viewmodel中的
bind
时为
null
。如果viewmodel是一个组件,并且该组件所属视图在其
bind
钩子中的异步操作中传播了可绑定字段,则可能发生
字段
为“静止”的情况组件的
bind
hook中未定义。据我所知,唯一等待完成的钩子是
activate
hook.imo“变量应该在
bind()
阶段填充”应该是“变量可以在
bind()
阶段填充”。同样,如果拥有的viewmodel在其
bind()
钩子中的一个长异步操作中解析了
字段的表示形式,则
字段很可能在
子对象中未定义。如果要确保在父视图模型中解析的数据可以在子组件的
绑定
钩子中访问,则需要在父视图模型的
附加
钩子中解析数据。
constructor:  undefined
bind:  test
attached:  test