完整的Login.js
shouldOverrideUrlLoading(WebView view, String url)
您好,我正在努力学习React Native;我在IOS中创建了一个原生应用程序,当我编写导航器时,我在Login.js中遇到了这个问题,任何人都可以帮助我吗?这是我的代码: index.ios.js: StackNavigator的配置
'use strict'
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
Image,
TouchableHighlight,
View,
Alert
} from 'react-native';
import { StackNavigator } from 'react-navigation'
class login extends Component{
static navigationOptions = {
title: 'Login'
}
render() {
return (
<View style={styles.contenedor} >
<Text style={styles.title}>La App chula</Text>
<TouchableHighlight style={styles.boton} onPress={(this.onLogin.bind(this))}>
<Text style={styles.letra}>Login</Text>
</TouchableHighlight>
</View>
);
}
onLogin = () => {
Alert.alert(
'Acceso',
'Te has logueado en el sistema',
[
{text: 'Aceptar',
onPress:(() => this.prop.navigation.navigate('Dashboard'))},
{text: 'Cancelar',
onPress:(this.cancelar.bind(this))}
]
)
}
cancelar(){
console.log(this.props)
}
}
const styles = StyleSheet.create({
contenedor:{
flex: 1,
/*justifyContent: 'center', /*Alineado Horizontalmente */
alignItems: 'center', /*Alineado Vertical*/
},
boton:{
backgroundColor: 'red',
alignItems: 'center',
justifyContent: 'center',
width: 300,
height: 30,
marginTop: 60,
marginBottom: 5,
borderRadius: 5,
},
letra:{
color: 'white',
},
title:{
fontSize: 25,
marginTop: 100,
},
});
module.exports = login
在Login.js中我们有一个警报;当你接受它带你到仪表板时,我们首先在登录组件中有一个navigationOptions,我们在仪表板组件中有其他类似的东西:
const IndexApp = StackNavigator({
Login: {screen: Login},
Dashboard: {screen: Dashboard}
在同一个文件中:
class login extends Component{
static navigationOptions = {
title: 'Login'
}