這是我目前工作的登錄頁面操作。一切工作正常反應本地路由器通量撥打國際長途功能
import React, { Component } from 'react';
import {AlertIOS , StyleSheet , View , Text} from 'react-native';
import Button from 'react-native-button';
import {Actions } from 'react-native-router-flux';
class Login extends Component {
render() {
return (
<View>
<Text>Hello world this is login page</Text>
<Button onPress={Actions.login2}>Click </Button>
</View>
);
}
}
export default Login;
不過,我想先調用函數檢查用戶名和password.If它是正確的我想進入下一個畫面。我怎樣才能做到這一點。像下面的代碼一樣。我真正的問題是我無法弄清楚調用渲染方法之外Actions.ROUTE_NAME
方法。
//This is not working
import React, { Component } from 'react';
import {AlertIOS , StyleSheet , View , Text} from 'react-native';
import Button from 'react-native-button';
import {Actions } from 'react-native-router-flux';
class Login extends Component {
controlMethod(){
if(true){Actions.login2}
}
render() {
return (
<View>
<Text>Hello world this is login page</Text>
<Button onPress={this.controlMethod}>Click </Button>
</View>
);
}
}
export default Login;
這可能會回答你的問題:https://stackoverflow.com/questions/37346979/how-to-call-actions-xxx-in-functions-binded-to-onpress-event-in-react-native-ro – jamesw