File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ Picker 选择器
3
3
4
4
解决 ios 与 android 和用户交互方式不同问题.
5
5
6
- > 避免出现样式错乱问题, 请尽量使用统一数字高度 。
6
+ > 避免出现样式错乱问题, 请尽量使用统一整数数字高度 。
7
7
> 激活状态尽量不要改变高度, 只是修改颜色作为标记。
8
8
<!--rehype:style=border-left: 8px solid #ffe564;background-color: #ffe56440;padding: 12px 16px;-->
9
9
Original file line number Diff line number Diff line change @@ -92,10 +92,10 @@ const Picker = (props: PickerProps) => {
92
92
containerHeight,
93
93
} ;
94
94
} , [ containerStyle , textStyle ] ) ;
95
- const getItemHeight = ( event : LayoutChangeEvent ) => {
95
+ const getItemHeight = ( event : LayoutChangeEvent , index : number ) => {
96
96
const { height } = event . nativeEvent . layout ;
97
97
const round = Math . round ( height ) ;
98
- ItemHeights ?. push ( round * ItemHeights . length + round ) ;
98
+ ItemHeights [ index ] = round * ItemHeights . length + round ;
99
99
} ;
100
100
101
101
const location = ( scrollY : number , index : number ) => {
@@ -158,7 +158,7 @@ const Picker = (props: PickerProps) => {
158
158
>
159
159
{ date . map ( ( item , index ) => (
160
160
< Pressable
161
- onLayout = { getItemHeight }
161
+ onLayout = { ( event : LayoutChangeEvent ) => getItemHeight ( event , index ) }
162
162
key = { index }
163
163
onPressOut = { Platform . OS === 'android' ? onTouchEnd : undefined }
164
164
onPress = { ( ) => {
You can’t perform that action at this time.
0 commit comments