我的 index.js 文件是这样的。
import {AppRegistry} from 'react-native';
import Navigation from "./Button/Navigation";
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => Navigation);
Navigation.js 文件如下所示。
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import gameScreen from '../screens/gameScreen'
import RouletteScreen from '../GameScreen/RouletteScreen'
const Stack = createStackNavigator();
function Navigation() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="gameScreen" component={gameScreen} />
<Stack.Screen name="RouletteScreen" component={RouletteScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default Navigation ;
ButtonScreen.js 文件如下所示。
import React, { Component } from 'react'
import { StyleSheet, Text, View, TouchableOpacity,Image,Alert } from 'react-native';
const ButtonScreen = props => {
const content = (
<View style= {[styles.button]}>
<Image source={require('../assets/icon/룰렛.png')} style={{
transform: [{scale: 0.37}],
}}
/>
</View>
)
return (
<TouchableOpacity onPress={() => props.navigation.navigate("RouletteScreen")}
>{content}</TouchableOpacity>
)
}
const styles = StyleSheet.create ({
button: {
top: 60,
flexDirection: 'row',
alignItems: 'center',
height: '30%',
width: '100%',
},
})
export default ButtonScreen;
我该如何处理? 我是初学者.... 我正在处理一个新页面,但我不断收到错误消息。这让我很难受。请给我一些帮助。 当前的错误是这样的。类型错误:未定义不是对象 'Object.keys(routeConfigs)'