我在标签容器方面遇到了一些麻烦。尝试进行标签导航,但是我的空白页没有标签,也没有错误,我想我缺少了一些东西。
这是Root.js
import {createBottomTabNavigator, createAppContainer} from 'react-navigation';
// import {fire, auth, database } from './config/Config';
import FeedScreen from '../src/screens/FeedScreen';
import LearnScreen from '../src/screens/LearnScreen';
import PlayScreen from '../src/screens/PlayScreen';
import ProfileScreen from '../src/screens/ProfileScreen';
const tabContainer = createBottomTabNavigator({
Feed: FeedScreen,
Learn: LearnScreen,
Play: PlayScreen,
Profile: ProfileScreen
});
const RootContainer = createAppContainer(tabContainer);
export default class Root extends React.Component {
render() {
return (
<View style={styles.container}>
<RootContainer />
</View>
);
}
}
我传递标签导航错误还是什么?为什么我有空白页。
答案 0 :(得分:0)
您的代码中存在导出问题。正确的方法:
const tabContainer = createBottomTabNavigator({
Feed: FeedScreen,
Learn: LearnScreen,
Play: PlayScreen,
Profile: ProfileScreen
},{
initialRouteName: 'Feed',
});
class Root extends React.Component {
render() {
return (
<View style={styles.container}>
<RootContainer />
</View>
);
}
}
export default createAppContainer(tabContainer);
我还添加了initialRouteName: 'Feed',
,您可以这样使用,首先要显示哪个页面。