react native在static中使用this方法

方法一
首先需要在componentDidMount(){}中动态的添加点击事件

属性给params

componentDidMount(){
    this.props.navigation.setParams({
        title:'Save,
        navigatePress:this.clickSave
    })
}
clickSave = () => {
    alert('点击headerRight中的保存');
    console.log(this.props.navigation);
}
接下来就可以通过params方法来获取点击事件了
static navigationOptions = ({ navigation}) => ({
        title: navigation.state.params.title,
        headerRight:(
            <Text onPress={() => navigation.state.params.navigatePress()}>
                保存
            </Text>
        )
});
方法二
let _this = null    // 在class之前定义

export default class MineScene extends Component {
  static navigationOptions = ({ navigation }) => ({


// ......       onPress={() => _this.clickSave() }


// ...... })


  componentDidMount() {     _this = this }


  clickSave = () => {
    alert('点击headerRight中的保存');
    console.log(this.props.navigation);
  }
// ......
// ......
// ......