List组件在使用时,建议同时定义width和height属性。
规则配置
// code-linter.json5
{
"rules": {
"@performance/init-list-component": "warn",
}
} 正例
@Component
struct Greeting {
@Builder myBuilder() {
List().width(10).height(10)
}
build() {
List() {
}.width(10).height(10);
}
}
@Builder function globalBuilder() {
List().width(10).height(10)
} 反例
@Component
struct Greeting {
@Builder myBuilder() {
// missing initialization of attribute 'height'
List().width(10)
}
build() {
// missing initialization of attribute 'width'
List().height(10);
}
}
@Builder function myBuilder() {
// missing initialization of attribute 'height'
List().width(10)
}