我想要实现标签航海家反应native.The链接从我得到的代码是 https://reactnavigation.org/docs/navigators/tab 的问题是,当我运行的代码我得到错误500型我也在最后附上error.Plz的图像解决问题,如果有任何人知道关于它的代码是....TabNavigator的是如何实现在本地做出反应
import React from 'react';
import {
AppRegistry,
Text,
} from 'react-native';
import { StackNavigator } from 'react-navigation';
class MyHomeScreen extends React.Component {
static navigationOptions = {
tabBarLabel: 'Home',
// Note: By default the icon is only shown on iOS. Search the showIcon option below.
tabBarIcon: ({ tintColor }) => (
<Image
source={require('./chats-icon.png')}
style={[styles.icon, {tintColor: tintColor}]}
/>
),
};
render() {
return (
<Button
onPress={() => this.props.navigation.navigate('Notifications')}
title="Go to notifications"
/>
);
}
}
class MyNotificationsScreen extends React.Component {
static navigationOptions = {
tabBarLabel: 'Notifications',
tabBarIcon: ({ tintColor }) => (
<Image
source={require('./notif-icon.png')}
style={[styles.icon, {tintColor: tintColor}]}
/>
),
};
render() {
return (
<Button
onPress={() => this.props.navigation.goBack()}
title="Go back home"
/>
);
}
}
const styles = StyleSheet.create({
icon: {
width: 26,
height: 26,
},
});
const MyApp = TabNavigator({
Home: {
screen: MyHomeScreen,
},
Notifications: {
screen: MyNotificationsScreen,
},
}, {
tabBarOptions: {
activeTintColor: '#e91e63',
},
});
AppRegistry.registerComponent('TabNavigator',() => MyApp);
当我运行这段代码我得到错误
即使我使用那个时候简单的堆栈导航器也是一样的错误 堆栈导航器的代码,我从这个链接
https://reactnavigation.org/docs/intro/
这是'source = {require('./ chats-icon.png')}'你的线还是只是示例代码? –