简体   繁体   English

迫使Aurelia进行脏检查

[英]Force dirty checking in Aurelia

I have an array of objects that I am binding to the DOM via a ValueConverter . 我有一个对象数组,我通过ValueConverter绑定到DOM。 Aurelia can't quite figure out what I'm doing in the ValueConverter , and so it isn't updating properly. Aurelia无法弄清楚我在ValueConverter做了什么,所以它没有正确更新。 I want to force dirty checking on this object. 我想强制检查这个对象。 How can I do that? 我怎样才能做到这一点?

Expose your array via a property getter. 通过属性getter公开你的数组。

Instead of: 代替:

export class Foo {
  myArray = [];     // will be observed without dirty-checking
}

Use a property getter: 使用属性getter:

export class Foo {
  _myArray = [];   // internal value that you will manipulate as-needed

  get myArray() {  // this property will be dirty-checked.
    return this._myArray;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM