美文网首页
react-native 解决navigationOptions

react-native 解决navigationOptions

作者: 向前Hell | 来源:发表于2017-07-19 20:12 被阅读0次

在最外部声明:

let that;

在class内部:

constructor(props){
        super(props);
        that = this;
}

在const * = StackNavigation({})中:

navigationOptions:{
            headerTitle: (
                <TouchableOpacity
                    style={{width: width - 80, alignItems: 'center'}}
                >
                    <Text>123</Text>
                </TouchableOpacity>
            ),
            headerRight: (
                <TouchableOpacity
                    style={{
                        justifyContent: 'center',
                        width: 80,
                        height: 50,
                        alignItems: 'center'
                    }}
                    onPress={()=>that.props.navigation.navigate('Msg')}
                >
                    <Image
                        style={{
                            height: 20,
                            width: 25,
                        }}
                        source={require('./icons/msg-icon.png')}
                    />
                </TouchableOpacity>
            ),
            headerLeft: (
                <TouchableOpacity
                    style={{
                        justifyContent: 'center',
                        width: 80,
                        height: 50,
                        alignItems: 'center'
                    }}
                    onPress={() => that.props.navigation.navigate('Find')}
                >
                    <Image
                        style={{
                            height: 25,
                            width: 25,
                        }}
                        source={require('./icons/find-icon.png')}
                    />
                </TouchableOpacity>
            ),

相关文章

网友评论

      本文标题:react-native 解决navigationOptions

      本文链接:https://www.haomeiwen.com/subject/ydlrkxtx.html