[ES6-iOSCode]React Native三方组件之scrollable-tab-view

使用介绍

scrollable-tab-view 是RN的第三方组件,使用的时候我们需要做的是用npm导入到项目的组件管理文件夹下
组件下载地址:
https://github.com/skv-headless/react-native-scrollable-tab-view
安装方法:

1:终端窗口"cd 项目工程目录里"
执行命令:npm install react-native-scrollable-tab-view --save
 
2:安装成功后在工程文件里引入:
[ES5语法如下,RN最新的版本已经不可以使用]
 var ScrollableTabView = require('react-native-scrollable-tab-view');
[ES6语法如下]
import 组件类命名,{类型,}from '第三方组件名'
import ScrollableTabView, { DefaultTabBar, } from 'react-native-scrollable-tab-view';

组件查看:

[ES6-iOSCode]React Native三方组件之scrollable-tab-view_第1张图片
ls-scrollable-tab-view.png

具体实例代码:

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
   ProgressViewIOS
} from 'react-native';


import ScrollableTabView, { DefaultTabBar, } from 'react-native-scrollable-tab-view';
class TabBarView extends Component {
  render() {
    return (
    
      
        
          城市工资排行
        
        
        
        
        
        
        
      

      
        
          行业工资排行
        
        
        
        
        
        
        
    

      
        
          职业工资排行
        
        
        
        
        
        
        
      

    

    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
  progressView: {
    marginTop: 20,
    marginLeft:10,
    marginRight:10,

  },
  phoneContainer :{
    borderColor:"rgb(241,241,241)",
    backgroundColor:"rgb(255,255,255)",
    flex:1,
    borderStyle:"solid",
    borderWidth:1,
    margin:10,
    borderRadius:3,
    shadowColor: "rgb(229,229,229)",
    shadowOpacity: 0.5,
    shadowRadius: 2,
    shadowOffset: {
      height: 3,
      width: 3
    }
  }
});

AppRegistry.registerComponent('TabBarView', () => TabBarView);

效果图:

[ES6-iOSCode]React Native三方组件之scrollable-tab-view_第2张图片
scrollable-tab-view.gif

Demo源码下载: http://pan.baidu.com/s/1o762aQe 密码: 87k6

你可能感兴趣的:([ES6-iOSCode]React Native三方组件之scrollable-tab-view)