在编写演示stacknavigation应用程序时,我遇到了semulator声明的错误 "路线'主要'应该宣布一个屏幕。例如:
从' ./ MyScreen'中导入自选画面 ... 主要:{ 屏幕:MyScreen, } C:\ RN \博客\ node_modules \反应导航\ SRC \路由器\ validateRouteConfigMap.js:23:8 validateRouteConfigMap C:\ RN \博客\ node_modules \反应导航\ SRC \路由器\ validateRouteConfigMap.js:18:21 默认 C:\ RN \博客\ node_modules \反应导航\ SRC \路由器\ StackRouter.js:47:25 默认 C:\ RN \博客\ node_modules \反应导航\ SRC \导航\ StackNavigator.js:51:29 ...... "
为什么会发生这种情况我不知道任何人都有任何想法? 剩余代码在
之下
import React from 'react';
import { Text, View } from 'react-native';
import MainScreen from './MainScreen';
import RegisterScreen from './RegisterScreen';
import { StackNavigator } from 'react-navigation';
const ScreenList = StackNavigator({
Main: {
screen: MainScreen,
},
Register: {
screen: RegisterScreen,
},
});
export default ScreenList;

import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import MainScreen from './src/screens/MainScreen';
import ScreenList from './src/screens/ScreenList';
export default class App extends Component<{}> {
render() {
return (
<View>
<ScreenList />
</View>
);
}
}
&#13;
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { Card, Button, CardSection } from '../components/common/Index';
import Login from '../components/Login';
import ScreenList from './ScreenList';
export default class MainScreen extends Component {
render() {
return (
<View>
<Card>
<Login />
</Card>
<Text>----------------------------------</Text>
<Card>
<CardSection>
<Button>Register</Button>
</CardSection>
</Card>
</View>
);
}
}
&#13;
答案 0 :(得分:0)
猜测,也许您还没有导出MainScreen
组件。如果您可以共享mainScreen文件代码,它会有所帮助。
答案 1 :(得分:0)
可能是进口问题。尝试删除
来自App.js的import MainScreen from './src/screens/MainScreen';
或任何地方。它应该工作。