react-native-table-component, react-native 表格
使用 react-native-table-component, 加上 FlatList 组件,实现可以下拉刷新,上拉加载的demo
import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
  ScrollView,
  FlatList
} from 'react-native';
import { Table, TableWrapper, Row } from 'react-native-table-component';
export default class Index extends Component {
    constructor(props) {
        super(props);
        this.state = {
            tableHead: ['Head', 'Head2', 'Head3', 'Head4', 'Head5', 'Head6', 'Head7', 'Head8', 'Head9'],
            widthArr: [, , , , , , , , ],
            refreshing: false,
            tableData: []
        }
    }
    componentDidMount() {
        const tableData = [];
        for(let i = ; i < ; i += ) {
            const rowData = [];
            for(let j = ; j < ; j += ) {
                rowData.push(`${i}${j}`);
            }
            tableData.push(rowData);
        }
        this.setState({
            tableData: tableData
        })
    }
    refresh = () => {
        this.setState({
            refreshing: true
        })
        setTimeout(()=>{
            this.setState({
                refreshing: false
            })
        },)
        console.log('刷新视图');
    }
    //分页
    pager = () => {
        alert("分页加载数据");
    }
    render() {
        const state = this.state;
        const {
            widthArr,
            tableHead,
            tableData,
            refreshing
        } = this.state
        return(
            <View style={styles.container}>
                <ScrollView horizontal={true}>
                  <View>
                    <Table borderStyle={{borderColor: '#C1C0B9'}}>
                      <Row data={tableHead} widthArr={widthArr} style={styles.header} textStyle={styles.text}/>
                    </Table>
                      <Table style={{borderColor: '#C1C0B9'}}>
                          <FlatList
                            //刷新
                          onRefresh={this.refresh}
                          refreshing = {refreshing}
                          //分页
                          onEndReachedThreshold={0.1}
                          onEndReached={this.pager}
                          //没数据加载
                          ListEmptyComponent = {this._noData}
                          //分割线
                          ItemSeparatorComponent={this._separator}
                          data={ tableData }
                          keyExtractor={(item, index)=>index}
                          renderItem={({item, index}) =>{
                             return     <Row
                                  key={index}
                                  data={item}
                                  widthArr={widthArr}
                                  style={[styles.row, index% && {backgroundColor: '#F7F6E7'}]}
                                  textStyle={styles.text}
                                />
                              }}
                        />
                      </Table>
                  </View>
                </ScrollView>
             </View>
        )
    }
    //没有数据的时候加载
    _noData = () => {
        return <Text style={styles.noData}>没有数据</Text>;
    }
}
const styles = StyleSheet.create({
    container: {
        flex: ,
        paddingTop: ,
        backgroundColor: '#fff'
    },
    header: {
        height: ,
        backgroundColor: '#537791'
    },
    text: {
        textAlign: 'center',
        fontWeight: ''
    },
    row: {
        height: ,
        backgroundColor: '#E7E6E1'
    }
});
react-native-table-component, react-native 表格的更多相关文章
- React Native 中 component 生命周期
		
React Native 中 component 生命周期 转自 csdn 子墨博客 http://blog.csdn.net/ElinaVampire/article/details/518136 ...
 - React Native 系列(二) -- React入门知识
		
前言 本系列是基于React Native版本号0.44.3写的,最初学习React Native的时候,完全没有接触过React和JS,本文的目的是为了给那些JS和React小白提供一个快速入门,让 ...
 - React-Native(三):React Native是基于React设计的
		
React Native是基于React js设计的. 参考:<React 入门实例教程> React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript ...
 - 【React Native开发】React Native移植原生Android项目(4)
		
),React Native技术交流4群(458982758),请不要反复加群!欢迎各位大牛,React Native技术爱好者加入交流!同一时候博客左側欢迎微信扫描关注订阅号,移动技术干货,精彩文章 ...
 - [React Native] Installing and Linking Modules with Native Code in React Native
		
Learn to install JavaScript modules that include native code. Some React Native modules include nati ...
 - 用 React 编写移动应用 React Native
		
转载:用 React 编写移动应用 React Native ReactNative 可以基于目前大热的开源JavaScript库React.js来开发iOS和Android原生App.而且React ...
 - React 实现 Table 的思考
		
琼玖 1 年前 (写的零零散散, 包括github不怎么样) Table 是最常用展示数据的方式之一,可是一个产品中往往很多非常类似的 Table, 但是我们碰到的情况往往是 Table A 要排序, ...
 - React 中的 Component、PureComponent、无状态组件 之间的比较
		
React 中的 Component.PureComponent.无状态组件之间的比较 table th:first-of-type { width: 150px; } 组件类型 说明 React.c ...
 - React.createClass 、React.createElement、Component
		
react里面有几个需要区别开的函数 React.createClass .React.createElement.Component 首选看一下在浏览器的下面写法: <div id=" ...
 - mysqldump: Couldn't execute 'SHOW VARIABLES LIKE 'ndbinfo_version'': Native table 'performance_schema'.'session_variables' has the wrong structure (1682)
		
centos7.5 导出整个数据库报错 问题: [root@db01 ~]# mysqldump -uroot -pBgx123.com --all-databases --single-transa ...
 
随机推荐
- Redis不支持ssl
			
一直在公司内部推荐redis做cache管理,今天偶然想起虽然C#没问题,可是c/c++没查过可不可行. 结果查了一下,还真tmd有问题,官方的c client版本只支持linux side的,根本没 ...
 - 发送ajax步骤
			
1.创建异步对象 一般命名为xhr var xhr = new XMLHttpRequest(); 2. 设置请求行 open(请求方式,请求url) 1.get 需要在url后 ...
 - Java高级特性 第8节 网络编程技术
			
一.网络概述 1.网络的概念和分类 计算机网络是通过传输介质.通信设施和网络通信协议,把分散在不同地点的计算机设备互连起来,实现资源共享和数据传输的系统.网络编程就就是编写程序使联网的两个(或多个)设 ...
 - 弹出的 Dialog 里,包含 Form,如何在关闭 Dialog 时,执行 resetFields(对整个表单进行重置,将所有字段值重置为初始值并移除校验结果)
			
做法: before-close 事件中,调用 resetFields 取消按钮事件中,调用 resetFields <el-dialog title="弹出窗口" :vis ...
 - [转]ORACLE 11G 导出报错(EXP-00003)未找到段 (0,0) 的存储定义
			
http://blog.csdn.net/qq_19524879/article/details/51313205 ORACLE 11G 导出报错(EXP-00003)未找到段 (0,0) 的存储定义 ...
 - Azure CosmosDB (6) 冲突类型和解决策略
			
<Windows Azure Platform 系列文章目录> 当我们为CosmosDB配置多个Azure Region写入,就需要考虑冲突类型和解决策略. 对于配置了多个写入区域的 Az ...
 - 运用scrollPic插件的实例
			
html页面部分 <!doctype html> <html lang="en"> <head> <meta charset=" ...
 - Windows自定义运行命令
			
1 打开注册表regedit 2 找到:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths 3 新增项,自己运 ...
 - ubuntu16.04 install qtcreator
			
1. 安装相关软件,搭建环境 sudo apt install qt-creator sudo apt install qt5-default source python35/bin/activate ...
 - [UE4]Spline
			
Spline和Spline Mesh的区别: 1.Spline Mesh是有实体表现的,Spline Mesh可以拉伸弯曲实体模型,Spline Mesh是具象. 2.Spline 只有曲线,没有实体 ...