我需要使用onPress动态更改customNavbar按钮,如下所示:
首先,我将导航栏加载到componentDidMount中,这部分工作正常
componentDidMount(){
this.props.navigator.setStyle({
navBarCustomView: 'CustomHeader',
navBarComponentAlignment: 'center',
topBarElevationShadowEnabled: false,
navBarNoBorder: false,
navBarTransparent: true,
screenBackgroundColor: 'white',
navBarBackgroundColor: 'white',
navBarCustomViewInitialProps: {
rightComponentRightSide: (
<NavButton title="Next" onPress={onClickNext} />
),
},
});
}
然后我需要在用户按下next按钮时,将按钮更改为其他自定义按钮,这种方式让我很累,但是它不起作用
onClickNext() {
this.props.navigator.setStyle({
navBarCustomView: 'CustomHeader',
navBarComponentAlignment: 'center',
topBarElevationShadowEnabled: false,
navBarNoBorder: false,
navBarTransparent: true,
screenBackgroundColor: 'white',
navBarBackgroundColor: 'white',
navBarCustomViewInitialProps: {
rightComponentRightSide: (
<LoadButton title="loading" />
),
},
});
}