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);
return newColumn;
});
let emptyText;
let emptyRowKey;
// Empty Data
let emptyRowKey;
if (!data || data.length === 0) {
emptyText = (
<div className="ant-table-placeholder">
{locale.emptyText}
</div>
);
columns.forEach((column, index) => {
columns[index].render = () => ({
children: !index ? emptyText : null,
column.render = () => ({
children: !index ? <div className="ant-table-placeholder">{locale.emptyText}</div> : null,
props: {
colSpan: !index ? columns.length : 0,
},

View File

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