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 ...
随机推荐
- 2_PY基本数据类型
python的数据类型和R差不多,但是需要注意的是字符访问方式与R不一样,另外,python中的“真”和“假”是True False(首字母大写). 1.字符串 字符串和R的定义差不多比如: data ...
- C/C++ 控制台字体的变颜变色
先扔一个链接上来,因为怕忘: https://blog.csdn.net/stude/article/details/7645056 https://blog.csdn.net/lindorx/art ...
- 存储专栏:一句话说清RAID2.0
今天,西瓜哥来谈谈高端存储的一股势力,RAID 2.0,最近被华为HVS搞得风生水起,神奇的让人摸不着头脑.我还是从一个高端存储的江湖说起吧. 据说很久很久以前(别扔臭鸡蛋,讲故事都是这样的…),L ...
- Windows 7 X64平台编译LLVM+clang
1 源码包 去LLVM官方网站下载最新的源码,Windows平台下载三个即可(2019.04.24版本为LLVM 8.0.0): LLVM source code (.sig) Clang sourc ...
- pip改源
临时 python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple django==1.10 # ==后边指定版本号,也可以不指定 ...
- pdf.js的使用
下载地址: files.cnblogs.com/zycjwdss/mypdf.zip 把下载后的zip解压,放到web服务器根目录下,打开pdf.html,把这一句取消注释: //window.pd ...
- 在 Linux 系统中读取 GBK 编码的文档
Linux 系统中,默认使用 UTF-8 编码.有时,我们下载的一些文件(比如 TXT 电子书,中文字幕等)使用了 GBK 编码,这样,当我们读取这些文件时,就会看到乱码.一般来说,有两种解决办法. ...
- 语音通信中终端上的时延(latency)及减小方法
时延是语音通信中的一个重要指标,当端到端(end2end)的时延(即one-way-delay,单向时延)低于150Ms时人感觉不到,当端到端的时延超过150Ms且小于450Ms时人能感受到但能忍受不 ...
- 转 Ubuntu16.04+QT4.8.7开发环境搭建
Qt安装步骤1.安装g++以及依赖库 sudo apt-get install g++ sudo apt-get install g++-multilib libx11-dev libxext-de ...
- nginx1.14.0版本location路径配置四种方式
假设下面四种情况分别用 http://192.168.1.1/proxy/test.html 进行访问. 第一种:location /proxy/ { proxy_pass http:// 12 ...