React后台管理系统-table-list组件
table-list组件可用于商品列表,用户列表页面
需要传入一个tableHeads集合和tablebody
- import React from 'react';
- // 通用的列表
- class TableList extends React.Component{
- constructor(props){
- super(props);
- this.state = {
- isFirstLoading: true
- }
- }
- componentWillReceiveProps(){
- // 列表只有在第一次挂载的时候,isFirstLoading为true,其他情况为false
- this.setState({
- isFirstLoading : false
- });
- }
- render(){
- // 表头信息
- let tableHeader = this.props.tableHeads.map(
- (tableHead, index) => {
- if(typeof tableHead === 'object'){
- return <th key={index} width={tableHead.width}>{tableHead.name}</th>
- }else if(typeof tableHead === 'string'){
- return <th key={index}>{tableHead}</th>
- }
- }
- );
- // 列表内容
- let listBody = this.props.children;
- // 列表的信息
- let listInfo = (
- <tr>
- <td colSpan={this.props.tableHeads.length} className="text-center">
- {this.state.isFirstLoading ? '正在加载数据...' : '没有找到相应的结果~'}</td>
- </tr>
- );
- //当listBody.length<=0,第一次加载的时候firstLoading=true,显示"正在加载数据"
- //当listBody.length<=0,第一次加载的时候firstLoading=false,显示"正在加载数据"
- let tableBody = listBody.length > 0 ? listBody : listInfo;
- return (
- <div className="row">
- <div className="col-md-12">
- <table className="table table-striped table-bordered">
- <thead>
- <tr>
- {tableHeader}
- </tr>
- </thead>
- <tbody>
- {tableBody}
- </tbody>
- </table>
- </div>
- </div>
- );
- }
- }
- export default TableList;
React后台管理系统-table-list组件的更多相关文章
- React后台管理系统-添加商品组件
引入了CategorySelector 二级联动组件.FileUploader图片上传组件和RichEditor富文本编辑组件 import React from 'react'; import MU ...
- React后台管理系统- rc-pagination分页组件封装
1.用户列表页面使用的rc-pagination分页组件 Github地址: https://github.com/react-component/pagination 2.安装 cnpm insta ...
- React后台管理系统-首页Home组件
1.Home组件要显示用户总数.商品总数和订单总数,数据请求后端的 /manage/statistic/base_count.do接口,返回的是 this.state = { u ...
- 《React后台管理系统实战 :一》:目录结构、引入antd、引入路由、写login页面、使用antd的form登录组件、form前台验证、高阶函数/组件
实战 上接,笔记:https://blog.csdn.net/u010132177/article/details/104150177 https://gitee.com/pasaulis/react ...
- 【共享单车】—— React后台管理系统开发手记:AntD Table高级表格
前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...
- 【共享单车】—— React后台管理系统开发手记:AntD Table基础表格
前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...
- 【共享单车】—— React后台管理系统开发手记:主页面架构设计
前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...
- react后台管理系统路由方案及react-router原理解析
最近做了一个后台管理系统主体框架是基于React进行开发的,因此系统的路由管理,选用了react-router(4.3.1)插件进行路由页面的管理配置. 实现原理剖析 1.hash的方式 ...
- 《React后台管理系统实战 :三》header组件:页面排版、天气请求接口及页面调用、时间格式化及使用定时器、退出函数
一.布局及排版 1.布局src/pages/admin/header/index.jsx import React,{Component} from 'react' import './header. ...
随机推荐
- POJ1034 The dog task
题目来源:http://poj.org/problem?id=1034 题目大意: 一个猎人在遛狗.猎人的路径由一些给定的点指定.狗跟随着猎人,要与主人同时到达那些指定的点.在丛林里有一些有趣的地方, ...
- Python Unittest - Test Fixtures 测试夹具
一.什么是测试夹具 定义单个或者多个测试所需的环境准备(setUp),以及环境清理(tearDown). 例:连接数据库,或者创建Selenium WebDriver driver实例 二.测试夹具有 ...
- D. Beautiful numbers
题目链接:http://codeforces.com/problemset/problem/55/D D. Beautiful numbers time limit per test 4 second ...
- mybatis使用说明
起步:1.创建一个maven项目工程.2.打开pom.xml配置文件,3.设置源代码编码方式为UTF-8.4.设置编译源代码的JDK版本.最好大于1.6版本.5. 重点--添加Mybatis的相关依赖 ...
- (转)IE6 死后即将大快人心的10件事
(转)未来五年程序员应当具备的十项技能 W3C CSS 2.1 Specification(Quick Table of Contents) (转)IE6 死后即将大快人心的10件事 2009-04- ...
- aspx有"记住我"的登录
客户端 <form id="form1" runat="server"> <div> 用户名:<input type=" ...
- webpack.config.js====配置babel
参考:https://www.jianshu.com/p/9808f550c6a91. 安装依赖babel-loader: 负责 es6 语法转化babel-preset-env: 包含 es6.7 ...
- JavaSE_3_面向对象
1.wait方法底层原理 wait是object中的方法,可以暂停线程,会释放对象锁,不像sleep方法,线程休眠期依然持有锁,通过调用notify或notifyAll方法唤醒线程. lock.wai ...
- springboot 学习笔记(九)
springboot整合activemq,实现broker集群部署(cluster) 1.为实现jms高并发操作,需要对activemq进行集群部署,broker cluster就是activemq自 ...
- mysql5.6.31安装及配置
1,下载安装包解压到安装位置.下载地址https://dev.mysql.com/downloads/mysql/5.6.html#downloads 2,修改默认配置文件 在根目录下面有my-def ...