From 45463d2e16461b23cddefaaa6fa5bd113722c818 Mon Sep 17 00:00:00 2001 From: ShanaMaid Date: Tue, 6 Nov 2018 16:47:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20table=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89render?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Table/Table.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/Table/Table.tsx b/components/Table/Table.tsx index aa225d8..f622fc1 100644 --- a/components/Table/Table.tsx +++ b/components/Table/Table.tsx @@ -1,11 +1,10 @@ - +// tslint:disable no-any import {Component} from 'react'; import * as React from 'react'; import * as classNames from 'classnames'; import {IBaseComponent} from '../template/component'; export interface ITableProps extends IBaseComponent { - // tslint:disable-next-line no-any data: any[]; columns: IColumns[]; fixedTitle?: boolean; @@ -21,6 +20,7 @@ export interface IColumns { dataIndex: string; fixed?: 'left' | 'right'; style?: React.CSSProperties; + render?: (v: any) => void; } export interface ITableState { @@ -255,9 +255,14 @@ export class Table extends Component { return ( { - columns.map((column, index) => ( - {item[column.dataIndex]} - )) + columns.map((column, index) => { + const v = item[column.dataIndex]; + return ( + + {column.render ? column.render(v) : v} + + ); + } } );