加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactnative tabnavigator

发布时间:2020-12-15 06:38:15 所属栏目:百科 来源:网络整理
导读:这种效果相信大家见的很多,那么是怎么实现的呢?使用的是reactNavigation 代码如下 import React,{Component} from 'react';import {View,Text,Image,ActivityIndicator,StyleSheet,Dimensions,Animated,Easing} from 'react-native';import {StackNavigato

这种效果相信大家见的很多,那么是怎么实现的呢?使用的是reactNavigation

代码如下

import React,{Component} from 'react';
import {
	View,Text,Image,ActivityIndicator,StyleSheet,Dimensions,Animated,Easing
} from 'react-native';

import {
	StackNavigator,TabNavigator,} from 'react-navigation'

import ShopInfo from './ShopInfo';
import ShopUrl from './ShopUrl';
import ShopEvaluate from './ShopEvaluate';

const {width,height} = Dimensions.get('window');
const tabWidthPadding = (((width)/3)-30)/2;



const MainScreen = TabNavigator({
	shopInfo:{
		screen:ShopInfo,navigationOptions:{
			title:'商品',}
	},shopUrl:{
		screen:ShopUrl,navigationOptions:{
			title:'详情'
		}
	},shopEvaluate:{
		screen:ShopEvaluate,navigationOptions:{
			title:'评价'
		}
	}
},{
	tabBarOptions:{
		activeTintColor:'#000000',inactiveTintColor:'#666666',style:{
			backgroundColor:'white',height:50,},indicatorStyle:{
			height:3,width:30,backgroundColor:'#fa372d',marginLeft:tabWidthPadding,marginRight:tabWidthPadding,justifyContent:'center'
		}
	}
});

const Shop = StackNavigator({
	mainScreen:{
		screen:MainScreen,navigationOptions:{
			gesturesEnabled:true,header:null
		}
	}
})


export default class ShopHomeInfo extends Component{

	constructor(props){
		super(props)

	}

	render(){
		const {params} = this.props.navigation.state;
		return(
			<View style={styles.container}>
				<Shop style={{flex:1}} />
			</View>
		);
	}
}

const styles = StyleSheet.create({
  container:{
  	width:width,height:height,})

ShopInfo.js的代码如下
import React,ScrollView,} from 'react-native';

export default class ShopInfo extends Component{

	constructor(props){
		super(props)
		this.state={

		}
	}

	componentDidMount(){

	}

	render(){
		return(
			<View>
				<Text>商品信息参数是:</Text>
			</View>
		);
	}

}

ShopUrl.js
import React,WebView,} from 'react-native';

export default class ShopUrl extends Component{

	render(){
		return(
			<WebView 
				source={{uri:'http://blog.csdn.net/u010648159/article/details/78636281'}}
				style={{flex:1}}
			/>
		);
	}
}

ShopEvaluate.js
import React,} from 'react-native';

export default class ShopEvaluate extends Component{

	render(){
		return(
			<View style={{width:50,height:50}}>
				<Text>商品评价</Text>
			</View>
		);
	}
}
就是这么的简单,如果如果要在导航栏加上左边返回按钮,就比较麻烦了,大家可以想一想啊!!!!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读