Skip to content

Commit c289285

Browse files
committed
feat(taro-components-rn): 让 SwiperItem 支持 onClick, close #1564
1 parent 2b420a6 commit c289285

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/taro-components-rn/example/EXSwiper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class EXSwiper extends Component {
2020
backgroundColor: 'black'
2121
}}
2222
>
23-
<SwiperItem style={{ backgroundColor: 'red' }}>
23+
<SwiperItem onClick={() => { alert('click item') }} style={{ backgroundColor: 'red' }}>
2424
<Text>Hello Swiper</Text>
2525
</SwiperItem>
2626
<SwiperItem style={{ backgroundColor: 'green' }}>

packages/taro-components-rn/src/components/Swiper/SwiperItem.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import * as React from 'react'
66
import {
77
// Text,
8-
View,
8+
// View,
99
StyleSheet,
1010
} from 'react-native'
11+
import View from '../View'
1112
import styles from './styles'
13+
import utils from '../../utils'
1214

1315
type Props = {
1416
children?: React.Node,
@@ -33,7 +35,10 @@ class _SwiperItem extends React.Component<Props> {
3335
} = this.props
3436

3537
return (
36-
<View style={[styles.page, style]}>
38+
<View
39+
{...utils.omit(this.props, ['style'])}
40+
style={[styles.page, style]}
41+
>
3742
{children}
3843
</View>
3944
)

0 commit comments

Comments
 (0)