Improve code style

This commit is contained in:
afc163 2016-08-17 15:47:29 +08:00
parent 471743f4c7
commit 0670b05e50
2 changed files with 14 additions and 19 deletions

View File

@ -766,18 +766,13 @@ export default class Table extends React.Component {
newColumn.key = this.getColumnKey(newColumn, i); newColumn.key = this.getColumnKey(newColumn, i);
return newColumn; return newColumn;
}); });
let emptyText;
let emptyRowKey;
// Empty Data
let emptyRowKey;
if (!data || data.length === 0) { if (!data || data.length === 0) {
emptyText = (
<div className="ant-table-placeholder">
{locale.emptyText}
</div>
);
columns.forEach((column, index) => { columns.forEach((column, index) => {
columns[index].render = () => ({ column.render = () => ({
children: !index ? emptyText : null, children: !index ? <div className="ant-table-placeholder">{locale.emptyText}</div> : null,
props: { props: {
colSpan: !index ? columns.length : 0, colSpan: !index ? columns.length : 0,
}, },

View File

@ -11,9 +11,7 @@ import { Table } from 'antd';
const columns = [{ const columns = [{
title: '姓名', title: '姓名',
dataIndex: 'name', dataIndex: 'name',
render(text) { render: (text) => <a href="#">{text}</a>,
return <a href="#">{text}</a>;
},
}, { }, {
title: '资产', title: '资产',
className: 'column-money', className: 'column-money',
@ -40,13 +38,15 @@ const data = [{
address: '西湖区湖底公园1号', address: '西湖区湖底公园1号',
}]; }];
ReactDOM.render(<Table ReactDOM.render(
columns={columns} <Table
dataSource={data} columns={columns}
bordered dataSource={data}
title={() => '页头'} bordered
footer={() => '页脚'} title={() => '页头'}
/>, mountNode); footer={() => '页脚'}
/>
, mountNode);
```` ````
````css ````css