React Native 中 static的navigationOptions中的点击事件不能用this

想在某个页面中设置导航栏,title + 左右按钮(按钮上肯定需要有事件)

static navigationOptions =  ({ navigation, navigationOptions }) => ({

        title: '新建活动',
        //导航栏头部
        headerRight: <Button title='保存'
        onPress={()=>navigation.state.params.navigatePress()}
        />

    });
componentDidMount() {
      //Alert.alert(this.props.navigation)
      //在初始化render之后只执行一次,在这个方法内,可以访问任何组件,componentDidMount()方法中的子组件在父组件之前执行
      this.props.navigation.setParams({navigatePress:this.save})

    };
save() {}
此文仅为鄙人学习笔记之用,朋友你来了,如有不明白或者建议又或者想给我指点一二,请私信我。liuw_flexi@163.com/QQ群:582039935. 我的gitHub: (学习代码都在gitHub) https://github.com/nwgdegitHub/
原文地址:https://www.cnblogs.com/liuw-flexi/p/11544063.html