我是本机的新手,我为在屏幕之间导航创建了一个示例应用程序,但遇到了一些问题。我已附上屏幕快照。
我在App.js中使用的代码
import React from 'react';
import {Text, View } from 'react-native';
import { StackNavigator } from 'react-navigation';
import FirstScreen from './screens/FirstScreen'
import SecondScreen from './screens/SecondScreen'
const Navigation = StackNavigator({
First: {screen: FirstScreen},
Second: {screen: SecondScreen}
});
export default Navigation; // Export your root navigator as the root component
第二屏幕代码:
import React from 'react';
import {Text, View, Button} from 'react-native';
const util = require('util');
export default class SecondScreen extends React.Component {
static navigationOptions = {
title: 'Second screen',
};
render() {
console.log("this.props.navigation.state = " + util.inspect(this.props.navigation.state, false, null));
var {params} = this.props.navigation.state;
return (
<View>
<Text>This is screen 2</Text>
<Text>Params from screen1 : {params.name}, email = {params.email}</Text>
</View>
);
}
}
这些代码来自github。
答案 0 :(得分:0)