在 Aurelia 中强制进行脏检查
Force dirty checking in Aurelia
我有一个对象数组,我通过 ValueConverter
绑定到 DOM。 Aurelia 不太明白我在 ValueConverter
中做什么,因此它没有正确更新。我想强制对这个对象进行脏检查。我该怎么做?
通过 属性 getter.
公开您的数组
而不是:
export class Foo {
myArray = []; // will be observed without dirty-checking
}
使用 属性 getter:
export class Foo {
_myArray = []; // internal value that you will manipulate as-needed
get myArray() { // this property will be dirty-checked.
return this._myArray;
}
}
我有一个对象数组,我通过 ValueConverter
绑定到 DOM。 Aurelia 不太明白我在 ValueConverter
中做什么,因此它没有正确更新。我想强制对这个对象进行脏检查。我该怎么做?
通过 属性 getter.
公开您的数组而不是:
export class Foo {
myArray = []; // will be observed without dirty-checking
}
使用 属性 getter:
export class Foo {
_myArray = []; // internal value that you will manipulate as-needed
get myArray() { // this property will be dirty-checked.
return this._myArray;
}
}