我照着回答里面说的指定rn的版本为0.44.0 react-native-tab-navigator显示空白,也没有任何报错怎么回事
来源:1-5 项目底部导航菜单开发
慕婉清本尊
2018-06-19
import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View, Image } from 'react-native'; import TabNavigator from 'react-native-tab-navigator'; export default class imooc_old extends Component { constructor(props) { super(props) this.state = { selectedTab: 'home', } } render() { return ( <View style={styles.container}> <TabNavigator> <TabNavigator.Item selected={this.state.selectedTab === 'home'} title="Home" renderIcon={() => <Image source={require('./res/images/ic_polular.png')} />} renderSelectedIcon={() => <Image source={require('./res/images/ic_polular.png')} />} badgeText="1" onPress={() => this.setState({ selectedTab: 'home' })}> <View style={styles.page1}></View> </TabNavigator.Item> <TabNavigator.Item selected={this.state.selectedTab === 'profile'} title="Profile" renderIcon={() => <Image source={require('./res/images/ic_polular.png')} />} renderSelectedIcon={() => <Image source={require('./res/images/ic_polular.png')} />} onPress={() => this.setState({ selectedTab: 'profile' })}> <View style={styles.page2}></View> </TabNavigator.Item> </TabNavigator> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, page1:{ backgroundColor:'red' }, page2:{ backgroundColor:'yellow' } }); AppRegistry.registerComponent('imooc_old', () => imooc_old);
写回答
1回答
-
慕婉清本尊
提问者
2018-06-19
补充一下,外面不包裹View就可以正常显示了,就是直接return TabNavigator
也不知道这样合理合理,希望老师看到能解答下疑惑。很想知道为什么
012018-06-19
相似问题