cipchk / nz-schema-form

ng-zorro-antd form generation based on JSON-Schema
MIT License
40 stars 14 forks source link

优化:提升 widget 属性获取性能 #17

Closed cipchk closed 6 years ago

cipchk commented 6 years ago

使用 get 属性获取属性:

get format() {
    return this.widgetData.format || 'YYYY-MM-DD';
}

由于 widgetData 是同一个地址这倒置 schema 任意对象的改变可能会引起组件重新渲染。

nz-sf 在外部 Schema 的改变会重新渲染整个组件树,而其 Schema 在渲染过程中是固定不变,基于此,将所有属性的获取放在 ngOnInit 中,并将其转换成属性值,例如:

format: string;

ngOnInit() {
    this.format = this.widgetData.format || 'YYYY-MM-DD';
}

此项优化将影响所有小部件。