0
我想在react-navigation
中創建一個自定義left
按鈕。我需要此left
按鈕的onPress
事件才能轉到特定屏幕;我該怎麼做呢?理想情況下,我想遠離編寫我自己的redux導航,因爲它變得複雜。我可以不用REDX做到這一點嗎?反應導航和自定義左按鈕onPress?
我想在react-navigation
中創建一個自定義left
按鈕。我需要此left
按鈕的onPress
事件才能轉到特定屏幕;我該怎麼做呢?理想情況下,我想遠離編寫我自己的redux導航,因爲它變得複雜。我可以不用REDX做到這一點嗎?反應導航和自定義左按鈕onPress?
它很容易得到這個,試試這個:
const stackNavigatorConfiguration = {
// set first Screen
initialRouteName: 'Login',
// headerMode: 'none'(disable header)
// style of switching screens(options: modal/card)
mode: Platform.OS === 'ios' ? 'card' : 'card',
navigationOptions: ({navigation}) => ({
headerRight: <DrawerButton navigation={navigation} />,
headerBackTitle: null,
headerStyle: {
backgroundColor: '#282b3a'
},
headerTitleStyle: {
color: 'white'
},
// color of the back button
headerTintColor: 'white',
headerBackTitleStyle: {
color: 'white'
}
})
}
...
const DrawerButton = ({ navigation }) => (
<TouchableOpacity>
<Ionicons
style={styles.drawerIcon}
name='ios-menu-outline'
size={32}
onPress={() => navigation.navigate('DrawerOpen')}
/>
</TouchableOpacity>
)
您可以navigationOptions定義按鈕 - headerRight 有你的進口組件(見DrawerButton)