場(chǎng)景:首頁(yè)有兩個(gè)鏈接,分別跳轉(zhuǎn)到登錄頁(yè)面和注冊(cè)頁(yè)面特恬。
登錄頁(yè)面也有一個(gè)鏈接跳轉(zhuǎn)到注冊(cè)頁(yè)面徐钠,注冊(cè)頁(yè)面也有一個(gè)鏈接跳轉(zhuǎn)到登錄頁(yè)面。
android.index.js 代碼
/**
* Sample React Native App
* http://uminicmf.com
* auth:duerhong
* email:1186969412 qq:1186969412
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import Home from './Auth';
export default class dudu extends Component {
render() {
return (
<Home />
);
}
}
AppRegistry.registerComponent('dudu', () => dudu);
Auth.js 首頁(yè)代碼實(shí)現(xiàn)
'use strict';
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
Button,
ToastAndroid,
} from 'react-native';
import {TabNavigator,StackNavigator} from 'react-navigation';
import LoginScreen from './app/Login';
import RegisterScreen from './app/Register';
class SignIn extends Component {
_getpen(){
this.props.navigation.goBack();
}
render() {
const { navigate } = this.props.navigation;
return (
<View>
<Text>首頁(yè)</Text>
<Button
title="去登錄"
onPress={() =>navigate('Login', { name: 'Jane' })}
/>
<Button
title="去注冊(cè)"
onPress={() =>navigate('Register', { name: 'Jane' })}
/>
</View>
);
}
}
const App = StackNavigator({
Home: {
screen: SignIn,
navigationOptions: {
header: null // 無(wú)標(biāo)題欄
}
},
Login: {
screen: LoginScreen,
navigationOptions: {
header: null // 無(wú)標(biāo)題欄
}
},
Register: {
screen: RegisterScreen,
hnavigationOptions: {
header: null // 無(wú)標(biāo)題欄
}
},
});
module.exports = App;
login.js 代碼實(shí)現(xiàn)
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
Button,
} from 'react-native';
import {TabNavigator,StackNavigator} from 'react-navigation';
import RegisterScreen from './Register';
// import AuthScreen from './Auth';
class LoginScreen extends Component {
_getpen(){
this.props.navigation.goBack();
}
static navigationOptions = {
title: 'Welcome',
};
render() {
const { navigate } = this.props.navigation;
return (
<View>
<Text>登錄頁(yè)面</Text>
<Button
title="返回首頁(yè)"
onPress={() =>navigate('Home', { name: 'Jane' })}
/>
<Button
title="去注冊(cè)"
onPress={() =>navigate('Register', { name: 'Jane' })}
/>
</View>
);
};
}
const Apps = StackNavigator({
Logins: {
screen: LoginScreen,
navigationOptions: {
header: null // 無(wú)標(biāo)題欄
}
},
});
module.exports=Apps;
register.js代碼實(shí)現(xiàn)
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
Button,
} from 'react-native';
class RegisterScreen extends Component {
render() {
return (
<View>
<Text>注冊(cè)頁(yè)面</Text>
</View>
);
};
}
module.exports=RegisterScreen;