ant-design/components/table/demo/loading.md

69 lines
1.1 KiB
Markdown
Raw Normal View History

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 08:07:03 +08:00
## zh-CN
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
用属性 `loading` 控制表格加载中状态。
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
## en-US
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
Controll loading states by `loading` property.
2015-11-03 18:16:16 +08:00
````jsx
import { Table, Button } from 'antd';
const columns = [{
title: 'Name',
2016-05-03 14:15:29 +08:00
dataIndex: 'name',
2015-11-03 18:16:16 +08:00
}, {
title: 'Age',
2016-05-03 14:15:29 +08:00
dataIndex: 'age',
2015-11-03 18:16:16 +08:00
}, {
title: 'Address',
2016-05-03 14:15:29 +08:00
dataIndex: 'address',
2015-11-03 18:16:16 +08:00
}];
const data = [{
key: '1',
name: 'John Brown',
2015-11-03 18:16:16 +08:00
age: 32,
address: 'New York No. 1 Lake Park',
2015-11-03 18:16:16 +08:00
}, {
key: '2',
name: 'Jim Green',
2015-11-03 18:16:16 +08:00
age: 42,
address: 'London No. 1 Lake Park',
2015-11-03 18:16:16 +08:00
}, {
key: '3',
name: 'Joe Black',
2015-11-03 18:16:16 +08:00
age: 32,
address: 'Sidney No. 1 Lake Park',
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() {
return (
<div>
<Table columns={columns} dataSource={data} loading={this.state.loading} />
<Button type="primary" onClick={this.toggleLoading}>Switch loading state</Button>
</div>
);
2016-05-11 09:32:33 +08:00
},
});
2015-11-03 18:16:16 +08:00
ReactDOM.render(<App />, mountNode);
2015-11-03 18:16:16 +08:00
````