2017-08-29 58 views

回答

1

U可以使用DrawerNavigator中的contentComponent爲抽屜使用自定義React組件。

{ 
    drawerWidth: 200, 
    drawerPosition: 'right', 
    contentComponent: props => <ScrollView><DrawerItems {...props} /></ScrollView> 
} 

contentComponent可以是自定義的陣營類u可以寫它由什麼ü希望。

提供定製contentComponent
可以很容易地覆蓋由反應導航中使用的默認組件:

import { DrawerItems } from 'react-navigation'; 

const CustomDrawerContentComponent = (props) => (
    <View style={style.container}> 
    <DrawerItems {...props} /> 
    </View> 
); 

const styles = StyleSheet.create({ 
    container: { 
    flex: 1, 
    }, 
}); 

參見:https://reactnavigation.org/docs/navigators/drawer
定製抽屜例如:https://developerlife.com/2017/04/15/navigation-and-styling-with-react-native/