Skip to content

Commit a6117a5

Browse files
committed
fix(Picker): 修复无法自定义显示key属性
1 parent 1299a49 commit a6117a5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/core/src/Picker/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface PickerProps {
2525
/** 显示几行, 默认 3 */
2626
lines?: number;
2727
/** 指定需要显示的 key, 默认使用 data 的 label 属性 */
28-
key?: string;
28+
rowKey?: string;
2929
/** 需要渲染的数据 */
3030
data?: Array<PickerData>;
3131
/** item 容器样式 */
@@ -53,7 +53,7 @@ export interface PickerProps {
5353
const Picker = (props: PickerProps) => {
5454
const {
5555
lines = 3,
56-
key = 'label',
56+
rowKey = 'label',
5757
data = new Array<PickerData>(),
5858
containerStyle = {},
5959
textStyle = {},
@@ -203,11 +203,11 @@ const Picker = (props: PickerProps) => {
203203
location(ItemHeights![index], index);
204204
}}
205205
>
206-
{React.isValidElement(item.render?.(item[key], item, index)) ? (
207-
item.render?.(item[key], item, index)
206+
{React.isValidElement(item.render?.(item[rowKey], item, index)) ? (
207+
item.render?.(item[rowKey], item, index)
208208
) : (
209209
<View style={style.containerUn}>
210-
<Text style={current === index ? style.textAc : style.textUn}>{item[key]}</Text>
210+
<Text style={current === index ? style.textAc : style.textUn}>{item[rowKey]}</Text>
211211
</View>
212212
)}
213213
</Pressable>

0 commit comments

Comments
 (0)