jd-opensource / jd-opensource/taro-ui
关于 List 组件的一些建议
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 740
- PR merge metrics
- No merged PRs in 30d
Description
**这个功能解决了什么问题?**
List 组件可能在很多业务场景下使用,现在组件的实现不是足够灵活,下面提供一些更灵活的满足不同业务场景下对样式自定义的方案:
**补充信息**
1. List组件的单一样式很难满足所有需求,需要`customStyle` 及`customClass` 属性提供更多的样式灵活性,比如更换背景色/文字颜色等。并且我看到 `AtListItem` 的 `PropsType` 已经继承了`AtComponent`,其中是有这两个属性的,只是文档中没有提及,应该是没有实现功能,使用中也没有效果。
list.d.ts
```typescript
export interface AtListItemProps extends AtComponent {
...
}
```
base.d.ts
```
export interface AtComponent {
className?: string | string[] | { [key: string]: boolean }
customStyle?: string | CSSProperties
}
```
2. 通过ListItem 的 `children` 提供内容
现在为ListItem提供各种属性的方式是通过定义很多的Props,但是这样还是不够灵活,无法满足一些业务情况,预期定义Props不如把`children`开放出去:
比如实现在 ListItem 右侧添加`对号` Icon 目前的方案:
```
this.switchCurrentOrg(org.id)}
/>
```
修改后可以更灵活:
```
this.switchCurrentOrg(org.id)}
>
{text}
```
Contributor guide
Assessment
This issue has not been assessed yet.