react-native 解决navigationOptions

2017-07-19  本文已影响0人  向前Hell

在最外部声明:

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>
            ),
上一篇 下一篇

猜你喜欢

热点阅读