ExpandableList

ExpandableList 可展开/折叠的列表

代码示例

import { BfExpandableList } from '@bud-fe/react-taro-ui';
import { View } from '@tarojs/components';
import React from 'react';
import styles from './index.module.less';
interface IItem {
name: string;
age: number;
}
export default () => {
return (
<>
<BfExpandableList<IItem>
className={styles['list-container']}
data={[
{ name: '热苏斯', age: 25 },
{ name: '萨卡', age: 21 },
{ name: '马丁内利', age: 21 },
{ name: '厄德高', age: 25 },
{ name: '史密斯罗', age: 21 },
{ name: '托马斯', age: 25 },
]}
maxCount={3}
itemRender={(item, index) => (
<View className={styles['list-item']}>
{index}: {JSON.stringify(item)}
</View>
)}
/>
<BfExpandableList<IItem>
className={styles['list-container']}
data={[
{ name: '热苏斯', age: 25 },
{ name: '萨卡', age: 21 },
{ name: '马丁内利', age: 21 },
{ name: '厄德高', age: 25 },
{ name: '史密斯罗', age: 21 },
{ name: '托马斯', age: 25 },
]}
maxCount={2}
itemRender={(item, index) => (
<View className={styles['list-item']}>
{index}: {JSON.stringify(item)}
</View>
)}
/>
</>
);
};

API

属性名描述类型默认值
data列表数据unknown[](必选)
maxCount折叠状态时展示的最大个数number(必选)
itemRender每个列表项的渲染(item: unknown, index: number) => any(必选)
expandedText展开文案string'展开'
collapsedText收起文案string'收起'
dumi10:24