Reactjs 每个堆栈的默认导航样式
我有一个默认的导航样式,我想合并到我的所有堆栈中,所以我有这个对象Reactjs 每个堆栈的默认导航样式,reactjs,react-native,react-navigation,react-navigation-stack,Reactjs,React Native,React Navigation,React Navigation Stack,我有一个默认的导航样式,我想合并到我的所有堆栈中,所以我有这个对象 const navigationDefaultStyle = { headerStyle: { backgroundColor:"#fff", height:60}, headerTitle: (<View style={{marginTop:5, flex: 1, flexDirection: 'row', justifyContent: 'center' }}><Image style={{ wid
const navigationDefaultStyle = {
headerStyle: { backgroundColor:"#fff", height:60},
headerTitle: (<View style={{marginTop:5, flex: 1, flexDirection: 'row', justifyContent: 'center' }}><Image style={{ width:140, height: 36, marginTop: 0, marginRight: 5}} source={require('./app/images/logo.png')}/></View>),
headerRight: (<TouchableOpacity activeOpacity={0.8} onPress={ async () => {
navigation.navigate('Settings', {transitionStyle:'default'})
} } style={{ marginRight:15, marginTop:5 }}>
<Icon name="cog" type="light" color="#29317C" size={26} />
</TouchableOpacity>)
}
你可以试着通过导航道具
const navigationDefaultStyle = (navigation)=>{
return{
headerStyle: { backgroundColor:"#fff", height:60},
headerTitle: (<View style={{marginTop:5, flex: 1, flexDirection: 'row', justifyContent: 'center' }}><Image style={{ width:140, height: 36, marginTop: 0, marginRight: 5}} source={require('./app/images/logo.png')}/></View>),
headerRight: (<TouchableOpacity activeOpacity={0.8} onPress={ async () => {
navigation.navigate('Settings', {transitionStyle:'default'})
} } style={{ marginRight:15, marginTop:5 }}>
<Icon name="cog" type="light" color="#29317C" size={26} />
</TouchableOpacity>)
}}
const navigationDefaultStyle = (navigation)=>{
return{
headerStyle: { backgroundColor:"#fff", height:60},
headerTitle: (<View style={{marginTop:5, flex: 1, flexDirection: 'row', justifyContent: 'center' }}><Image style={{ width:140, height: 36, marginTop: 0, marginRight: 5}} source={require('./app/images/logo.png')}/></View>),
headerRight: (<TouchableOpacity activeOpacity={0.8} onPress={ async () => {
navigation.navigate('Settings', {transitionStyle:'default'})
} } style={{ marginRight:15, marginTop:5 }}>
<Icon name="cog" type="light" color="#29317C" size={26} />
</TouchableOpacity>)
}}
const Login = createStackNavigator({ SignIn: { screen: SignInScreen, navigationOptions: ({ navigation }) => (navigationDefaultStyle(navigation)) } });