您好,登錄后才能下訂單哦!
組件react-native-tab-navigator的使用
1、npm安裝,導入組件react-native-tab-navigator
import TabNavigator from 'react-native-tab-navigator';
2、代碼如下
<View style={styles.container}>
<TabNavigator>
<TabNavigator.Item
selected={this.state.selectedTab === 'home'}
selectedTitleStyle={styles.btselcttext}
title="Home"
renderIcon={() => <Image style={styles.image} source={require('./res/images/Home-home.png')} />}
renderSelectedIcon={() => <Image style={styles.image} source={require('./res/images/Home-home1.png')} />}
// badgeText="1"
onPress={() => this.setState({ selectedTab: 'home' })}>
<View style={styles.page}></View>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'messge'}
selectedTitleStyle={styles.btselcttext}
title="消息"
renderIcon={() => <Image style={styles.image} source={require('./res/images/Home-messge.png')} />}
renderSelectedIcon={() => <Image style={styles.image} source={require('./res/images/Home-messge1.png')} />}
// badgeText="1"
// renderBadge={() => <CustomBadgeView style={{backgroundColor:'red'}} />}
onPress={() => this.setState({ selectedTab: 'messge' })}>
<View style={styles.page}></View>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'shop'}
selectedTitleStyle={styles.btselcttext}
// title="shop"
renderIcon={() => <Image style={{width:34,height:34,marginTop:20}} source={require('./res/images/Home-shop.png')} />}
renderSelectedIcon={() => <Image style={{width:34,height:34,marginTop:20}} source={require('./res/images/Home-shop.png')} />}
// badgeText="1"
onPress={() => this.setState({ selectedTab: 'shop' })}>
<View style={styles.page}></View>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'find'}
selectedTitleStyle={styles.btselcttext}
title="發現"
renderIcon={() => <Image style={styles.image} source={require('./res/images/Home-find.png')} />}
renderSelectedIcon={() => <Image style={styles.image} source={require('./res/images/Home-find1.png')} />}
// badgeText="1"
onPress={() => this.setState({ selectedTab: 'find' })}>
<View style={styles.page}></View>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'profile'}
selectedTitleStyle={styles.btselcttext}
title="我的"
renderIcon={() => <Image style={styles.image} source={require('./res/images/Home-my.png')} />}
renderSelectedIcon={() => <Image style={styles.image} source={require('./res/images/Home-my1.png')} />}
// renderBadge={() => <CustomBadgeView />}
onPress={() => this.setState({ selectedTab: 'profile' })}>
<View style={styles.page1}></View>
</TabNavigator.Item>
</TabNavigator>
</View>
3、路由的嵌套容易造成布局的混亂,比如頭部標題等無法顯示
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。