我想使用屬性依賴關係來避免對計算屬性進行髒檢查。由於計算屬性所依賴的屬性不是基元,而是對象的屬性,所以我不知道如何使其工作。對象屬性的屬性依賴關係
代碼:
import {computedFrom} from 'aurelia-framework';
export class Person {
personData = {
firstName: 'John',
lastName: 'Doe',
// More attributes...
}
// ...
// Doesn't work:
@computedFrom('personData.firstName', 'personData.lastName')
// Neither does:
// @computedFrom('personData["firstName"], 'personData["lastName"]')
// Nor:
// @computedFrom('personData')
get fullName() {
return `${this.personData.firstName} ${this.personData.lastName}`;
}
// ...
}
已添加回來嗎? –