我正在爲我的公司構建CRM應用程序。在登錄頁面上,它是一個空頭。登錄後,用戶會看到銷售訂單列表。銷售訂單列表屏幕標題右側有一個註銷按鈕。當我按下注銷時,我重定向到登錄頁面,但在標題左側顯示一個帶有(「銷售訂單」)的後退按鈕。我已經嘗試通過靜態navigationOptions在我的AppNavigator類中將標題設置爲null,並嘗試了許多不同的方法將標題設置爲null,但標題始終顯示出來。由於某些原因,登錄頁面似乎無法識別navigationOptions。這裏是我的一些代碼供你參考..這很有趣,因爲在SalesOrderList和SalesOrderItem上設置navigationOptions工作得非常好,但Login.js上的標題總是希望由於某種原因可見....無法弄清楚! !幫幫我!我試過{header:null},{headerLeft:null},{headerVisible:false},{header {left:null}},{header {visible:false}},天知道還有什麼......無法在登錄屏幕上隱藏標題反應原生
AppNavigator.js
const routeConfiguration = {
App: { screen: App },
Login: { screen: Login },
SalesOrderList : { screen: SalesOrderList },
SalesOrderItem : { screen: SalesOrderItem },
};
const stackNavigatorConfiguration = {
initialRouteName: 'App',
headerMode: 'screen'
}
export default AppNavigator = StackNavigator(routeConfiguration,stackNavigatorConfiguration)
AppRegistry.registerComponent('crm',() => AppNavigator);
Login.js
export default class Login extends Component {
constructor(props){
super(props);
}
state = {
email: '',
password: '',
error: '',
loading: false,
loggedIn: null
};
onButtonPress() {
const { email, password } = this.state;
this.setState({
email: email.toString(),
password: password.toString(),
error: '',
loading: true,
loggedIn: false
});
console.log('Logins navigationOptions');
console.log(Login.navigationOptions);
this.onAuthSuccess();
const auth0 = new Auth0({ domain: 'crm.auth0.com', clientId: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX' });
// auth0
// .auth
// .passwordRealm({username: {email}, password: {password}, realm: "urn:auth0:crm"})
// .then(authResult =>
// console.log(authResult)
// )
// .catch(error =>
// console.error(error)
// )
}
onAuthSuccess() {
const { navigate } = this.props.navigation;
this.setState({
loading: false,
loggedIn: true
});
this.props.updateAppState({loggedIn: true});
console.log(this.props.navigation);
navigate('SalesOrderList', {updateAppState: this.props.updateAppState});
}
onAuthFailed() {
this.setState({
error: 'Authentication Failed',
loading: false,
loggedIn: false
});
this.props.updateAppState({loggedIn: false});
this.props.navigation.navigate('App');
}
static navigationOptions = { headerLeft: null, };
render() {
const { navigate } = this.props.navigation;
const { form, fieldStyles, loginButtonArea, errorMessage, welcome, container } = styles;
return (
<View style={styles.container}>
<Text style = {styles.labelText} >Login to ISSI CRM</Text>
<MKTextField
text={this.state.email}
onTextChange={email => this.setState({ email })}
textInputStyle={fieldStyles}
placeholder={'Email...'}
tintColor={MKColor.Teal}
/>
<MKTextField
text={this.state.password}
onTextChange={password => this.setState({ password })}
textInputStyle={fieldStyles}
placeholder={'Password...'}
tintColor={MKColor.Teal}
password={true}
/>
<Text style={errorMessage}>
{this.state.error}
</Text>
<View style={loginButtonArea}>
<LoginButton onPress={this.onButtonPress.bind(this)} />
</View>
</View>
);
}
}