使用 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 表格的更多相关文章

  1. React Native 中 component 生命周期

    React Native 中 component 生命周期 转自 csdn 子墨博客  http://blog.csdn.net/ElinaVampire/article/details/518136 ...

  2. React Native 系列(二) -- React入门知识

    前言 本系列是基于React Native版本号0.44.3写的,最初学习React Native的时候,完全没有接触过React和JS,本文的目的是为了给那些JS和React小白提供一个快速入门,让 ...

  3. React-Native(三):React Native是基于React设计的

    React Native是基于React js设计的. 参考:<React 入门实例教程> React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript ...

  4. 【React Native开发】React Native移植原生Android项目(4)

    ),React Native技术交流4群(458982758),请不要反复加群!欢迎各位大牛,React Native技术爱好者加入交流!同一时候博客左側欢迎微信扫描关注订阅号,移动技术干货,精彩文章 ...

  5. [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 ...

  6. 用 React 编写移动应用 React Native

    转载:用 React 编写移动应用 React Native ReactNative 可以基于目前大热的开源JavaScript库React.js来开发iOS和Android原生App.而且React ...

  7. React 实现 Table 的思考

    琼玖 1 年前 (写的零零散散, 包括github不怎么样) Table 是最常用展示数据的方式之一,可是一个产品中往往很多非常类似的 Table, 但是我们碰到的情况往往是 Table A 要排序, ...

  8. React 中的 Component、PureComponent、无状态组件 之间的比较

    React 中的 Component.PureComponent.无状态组件之间的比较 table th:first-of-type { width: 150px; } 组件类型 说明 React.c ...

  9. React.createClass 、React.createElement、Component

    react里面有几个需要区别开的函数 React.createClass .React.createElement.Component 首选看一下在浏览器的下面写法: <div id=" ...

  10. 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 ...

随机推荐

  1. c++——智能指针学习(shared_ptr和weak_ptr)

    先看一个例子:Stark和Targaryen家族你中有我,我中有你.我们设计以下类企图避免内存泄漏,使得析构函数都能调用到: #include<iostream> #include< ...

  2. JVM GC机制

    垃圾收集主要是针对堆和方法区进行. 回收机制: 现在的JVM基本都使用分代回收机制,把堆中内存区域分为新生代,老年代. 新生代: Eden(80%) Survivor0(10%) Survivor1( ...

  3. python中使用 C 类型的数组以及ctypes 的用法

    Python 在 ctypes 中为我们提供了类似C语言的数据类型, 它的用途(我理解的)可能是: (1) 与 其他语言(如 C.Delphi 等)写的动态连接库DLL 进行交换数据,因为 pytho ...

  4. AttributePriority

    还有AttributePriority,我们可以设置编译时优先级.如果我们对目标标记了多个aspect,这样postsharp就不确定注入先后顺序,这样不能确保正确性,在vs编译时候我们会看见警告:T ...

  5. 【C++】static关键字的总结

    转自 https://www.cnblogs.com/BeyondAnyTime/p/2542315.html C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的s ...

  6. .Net Core跨平台应用研究-HelloArm(串口篇)

    引言 为了验证采用dotnet core技术开发的物联网设备数据采集接入服务应用是否能在高性价比的linux嵌入式平台运行,针对dotnet core应用程序进行嵌入式linux环境的发布部署运行验证 ...

  7. 关于极限精简版系统(RAMOS专用)的说明(FAQ)

    关于极限精简版系统(RAMOS专用)的说明(FAQ) 对RAMOS-er来说,系统精简唯一的目的就是RAMOS,精简只为RAMOS而存在.我更喜欢听到大家把精简系统用于RAMOS,这里才应该是他的主战 ...

  8. kong插件应用

    插件概述 插件之于kong,就像Spring中的aop功能.在请求到达kong之后,转发给后端应用之前,你可以应用kong自带的插件对请求进行处理,合法认证,限流控制,黑白名单校验,日志采集等等.同时 ...

  9. node-js:文摘

    ES6相关 1.module.exports与exports,export与export default之间的关系和区别 nodejs基础 1.NodeJs安装与全局配置(不建议修改包的全局安装路径, ...

  10. LeetCode【108. 将有序数组转换为二叉搜索树】

    又是二叉树,最开始都忘记了二叉搜索树是什么意思,搜索了一下: 二叉搜索树:左节点都小于右节点,在这里就可以考虑将数组中的中间值作为根节点 平衡二叉树:就是左右节点高度不大于1 树就可以想到递归与迭代, ...