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 ...
随机推荐
- 0. General-purpose tools (通用工具 8个)
http://en.wikipedia.org/wiki/Netcat这个简单的实用程序通过TCP或UDP网络连接读写数据. 它被设计为一个可靠的后端工具,可以直接或轻松地使用其他程序和脚本驱动. 同 ...
- Spring框架基础解析
Spring是一个轻量级的.非侵入式的容器框架:对Bean对象的生命周期进行管理. Spring框架的核心:IOC(控制反转).DI(依赖注入).AOP(面向切面编程). (1) IOC:控制反转. ...
- 20175202 《Java程序设计》第五周学习总结
20175209 2018-2019-2 <Java程序设计>第五周学习总结 教材知识点总结 1.接口声明: 使用关键字interface来定义接口. 定义接口时使用关键字interfac ...
- php 合并图片 (将活动背景图片和动态二维码图片合成一张图片)
<?php //案例一:将活动背景图片和动态二维码图片合成一张图片 //图片一 $path_1 = './background.png'; //图片二 $path_2 = './FU0851_2 ...
- py-day4-4 python 其他内置函数
# ascii码转换 print(chr(98)) 结果: b print(ord('b')) 结果: 98 # 求几的几次方 print(pow(2,3)) # 2**2 =2*2*2 结果: 8 ...
- 如何实现Proxifier只代理部分程序
转载自:https://jingyan.baidu.com/article/48b558e35e12f97f38c09a28.html 小编工作时上外网要通过局域网内其他人开代理,然后通过IE代理上网 ...
- mysql update where
UPDATE car_approval a JOIN car_distribute b ON a.id = b.APPROVAL_FOR_CAR_ID SET a.APPROVAL_STATUS = ...
- MS SQL 数据库所在C盘变得很大解决办法
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG 一般是这个文件夹里的ERRORLOG变得很大.所以要清理. 执行一次EXEC sp_cy ...
- C6678的PLL模块设置
这部分讲解的是Main PLL和 PLL Controller的配置,主要介绍怎样提供DSP核 C66X CorePac需要的工作时钟:C6678除了Main PLL,还有 DDR3 PLL.PASS ...
- Python高级变量类型
1.列表基础操作 2.列表循环遍历 3.元组 4.字典基础操作 5.字典循环遍历 6.字符串基础操作 7.字符串切片 8.公共方法