我遵循ReactNativeNotesForProfessionals.pdf这本书,并创建一个简单的React Native应用程序:
'use strict';
import React, {Component} from 'react';
import ReactNative from 'react-native';
const { StyleSheet, Text, View, Navigator, Alert, TouchableHighlight } = ReactNative;
class AppContainer extends Component {
renderScene(route, navigator) {
switch(route.name) {
case "Home":
return <Home route={route} navigator={navigator} {...route.passProps} />
default:
return (
<Text route={route}
style={styles.container}>
Your route name is probably incorrect {JSON.stringify(route)}
</Text>
);
}
}
render() {
return (
<Navigator
navigationBar={
<Navigator.NavigationBar
style={ styles.navbar }
routeMapper={ NavigationBarRouteMapper } />
}
initialRoute={{ name: 'Home' }}
renderScene={ this.renderScene }
/>
);
}
}
当我在Android设备的调试模式下运行该应用程序时,收到错误消息作为此帖子的标题。 我使用以下版本的React Native:
vhmau@ubuntu:~/Projects/Book$ react-native -v
react-native-cli: 2.0.1
react-native: 0.62.0
请帮助。