美文网首页
react native navigationOptions中不

react native navigationOptions中不

作者: 星小星啊 | 来源:发表于2019-01-08 11:48 被阅读0次

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

const { params } = navigation.state;

return {

tabBarVisible: true,

headerRight:(

navigation.state.params.navigatePress()}>

//this.order()

点餐

)

}

};

// 点击完成按钮

order = ()=> {

alert('haha');

}

componentDidMount() {

// 处理数据源

this.props.navigation.setParams({navigatePress:this.order})

}

方法二:

在最外部声明:

let that;

在class内部:

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

}

在const * = StackNavigation({})中:

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

const { params } = navigation.state;

return {

tabBarVisible: true,

headerRight:(

that.order()}>

点餐

)

}

};

order = ()=> {

alert('haha');

}

相关文章

网友评论

      本文标题:react native navigationOptions中不

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