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: '姓名',
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() {
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-03 18:16:16 +08:00
ReactDOM.render(<App />, mountNode);
2015-11-03 18:16:16 +08:00
````