2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 14
|
2016-08-15 07:54:01 +08:00
|
|
|
title:
|
|
|
|
en-US: Loading
|
|
|
|
zh-CN: 加载中的表格
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-11-03 18:16:16 +08:00
|
|
|
|
2016-08-15 07:54:01 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
Controll loading states by `loading` property.
|
|
|
|
|
|
|
|
# zh-CN
|
|
|
|
|
2015-11-03 18:16:16 +08:00
|
|
|
用属性 `loading` 控制表格加载中状态。
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Table, Button } from 'antd';
|
|
|
|
|
|
|
|
const columns = [{
|
|
|
|
title: '姓名',
|
2016-05-03 14:15:29 +08:00
|
|
|
dataIndex: 'name',
|
2015-11-03 18:16:16 +08:00
|
|
|
}, {
|
|
|
|
title: '年龄',
|
2016-05-03 14:15:29 +08:00
|
|
|
dataIndex: 'age',
|
2015-11-03 18:16:16 +08:00
|
|
|
}, {
|
|
|
|
title: '住址',
|
2016-05-03 14:15:29 +08:00
|
|
|
dataIndex: 'address',
|
2015-11-03 18:16:16 +08:00
|
|
|
}];
|
|
|
|
const data = [{
|
|
|
|
key: '1',
|
|
|
|
name: '胡彦斌',
|
|
|
|
age: 32,
|
2016-05-03 14:15:29 +08:00
|
|
|
address: '西湖区湖底公园1号',
|
2015-11-03 18:16:16 +08:00
|
|
|
}, {
|
|
|
|
key: '2',
|
|
|
|
name: '胡彦祖',
|
|
|
|
age: 42,
|
2016-05-03 14:15:29 +08:00
|
|
|
address: '西湖区湖底公园1号',
|
2015-11-03 18:16:16 +08:00
|
|
|
}, {
|
|
|
|
key: '3',
|
|
|
|
name: '李大嘴',
|
|
|
|
age: 32,
|
2016-05-03 14:15:29 +08:00
|
|
|
address: '西湖区湖底公园1号',
|
2015-11-03 18:16:16 +08:00
|
|
|
}];
|
|
|
|
|
|
|
|
const App = React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
2016-05-11 09:32:33 +08:00
|
|
|
loading: false,
|
2015-11-03 18:16:16 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
toggleLoading() {
|
|
|
|
this.setState({
|
2016-05-11 09:32:33 +08:00
|
|
|
loading: !this.state.loading,
|
2015-11-03 18:16:16 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
render() {
|
2016-01-07 16:29:12 +08:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Table columns={columns} dataSource={data} loading={this.state.loading} />
|
|
|
|
<Button type="primary" onClick={this.toggleLoading}>切换 loading 状态</Button>
|
|
|
|
</div>
|
|
|
|
);
|
2016-05-11 09:32:33 +08:00
|
|
|
},
|
2015-11-25 17:35:49 +08:00
|
|
|
});
|
2015-11-03 18:16:16 +08:00
|
|
|
|
2015-12-29 12:08:58 +08:00
|
|
|
ReactDOM.render(<App />, mountNode);
|
2015-11-03 18:16:16 +08:00
|
|
|
````
|