React Native 集成react-native-table-component(table表格插件)及代码示例
2019-01-15 10:54
736 查看
文章目录
- React Native 集成react-native-table-component(table表格插件)及代码示例
- 1、安装
- 2、使用
- 1):TableExample.js入口文件
- 2):效果图
- 3):本次使用到的第三方库
React Native 集成react-native-table-component(table表格插件)及代码示例
1、安装
#npm安装 npm install --save react-native-table-component
2、使用
1):TableExample.js入口文件
import React, {Component} from 'react'; import {Platform, StyleSheet, Text, TouchableOpacity, View} from 'react-native'; import {Row, Rows, Table} from 'react-native-table-component'; import {Button,Toast} from '@ant-design/react-native'; export default class TableExample extends Component { constructor(props) { super(...arguments); } render() { const options = { tableHead: ['name', 'sum', 'ok', 'no', 'stop', 'other'], tableData: [ ['RN 1', 125, 110, 15, 5, <Button type='primary' size='small' onPress={()=>Toast.info('You clicked on me ! !')}>查看</Button> ], [ 'RN 2', 525, 325, 200, 50, <Button type='primary' size='small' onPress={()=>Toast.info('You clicked on me ! !')}>查看</Button>], [ 'RN 3', 800, 500, 300, 100, <Button type='primary' size='small' onPress={()=>Toast.info('You clicked on me ! !')}>查看</Button>], [ '合计', 1450, 835, 515, 155, <Button type='primary' size='small' onPress={()=>Toast.info('You clicked on me ! !')}>查看</Button>] ] }; return ( <View style={styles.container}> <View style={styles.titleView}> <TouchableOpacity> <Text style={styles.titleStyle}> 数量统计 </Text> </TouchableOpacity> </View> <Table borderStyle={{borderWidth: 2, borderColor: '#c8e1ff'}}> <Row data={options.tableHead} style={styles.head} textStyle={styles.text}/> <Rows data={options.tableData} textStyle={styles.text}/> </Table> </View> ) } } const styles = StyleSheet.create({ container: {flex: 1, padding: 16, paddingTop: 30, backgroundColor: '#fff'}, head: { height: 40, backgroundColor: '#f1f8ff' }, text: { margin: 10, textAlign: 'center' }, titleView: { height: Platform.OS === 'ios' ? 64 : 44, paddingTop: Platform.OS === 'ios' ? 14 : 0, marginBottom: 10, backgroundColor: '#4a65ff', justifyContent: 'center', alignItems: 'center', flexDirection: 'row' }, titleStyle: { color: 'white', fontSize: 15, textAlign: 'center' } });
2):效果图
3):本次使用到的第三方库
- @ant-design/react-native(UI库)整合:https://blog.csdn.net/weixin_44187730/article/details/86094459
- react-navigation(导航组件)整合:https://blog.csdn.net/weixin_44187730/article/details/86092782
相关文章推荐
- React Native 集成 react-native-orientation(横竖屏插件)以及代码示例
- React Native 集成jpush-react-native的示例代码
- React Native 集成native-echarts(图表插件)及代码示例
- 【REACT NATIVE 系列教程之十一】插件的安装、使用与更新(示例:REACT-NATIVE-TAB-NAVIGATOR)
- [React Native] Use the SafeAreaView Component in React Native for iPhone X Compatibility
- react-native 完整实现登录功能的示例代码
- react native里react-navigation与redux + react-navigation-redux-helpers插件整合方法及样例代码
- react native 混合开发代码示例
- 用 jpush-react-native 插件快速集成推送功能(Android 篇)
- React Native集成react-native-fs(本地文件系统)
- React Native悬浮按钮组件的示例代码
- React Native 截屏组件的示例代码
- react-native 圆弧拖动进度条实现的示例代码
- [React Native混合开发]React Native for iOS之代码结构
- ios原生和react-native各种交互的示例代码
- 基于Metronic的Bootstrap开发框架经验总结(18)-- 在代码生成工具Database2Sharp中集成对Bootstrap-table插件的分页及排序支持
- React Native 集成jpush-react-native
- React Native集成react-native-qrcode-svg(二维码生成)
- react-native-tab-navigator组件的基本使用示例代码
- react-native-vector-icons在tab中的使用代码示例