diff --git a/components/affix/index.html b/components/affix/index.html index 391458898..1f8ae2a1a 100644 --- a/components/affix/index.html +++ b/components/affix/index.html @@ -594,18 +594,6 @@ Affix 固钉 - Ant Design 代码演示 -
一个通用的日历面板,支持年/月切换。
import { Calendar } from 'antd';
+
+function dateCellRender(value) {
+ return <div>自定义日数据 {value.getDayOfMonth()}</div>;
+}
+
+function monthCellRender(value) {
+ return <div>自定义月数据 {value.getMonth()}</div>;
+}
+
+ReactDOM.render(
+ <Calendar defaultValue={new Date('2010-10-10')}
+ dateCellRender={dateCellRender} monthCellRender={monthCellRender} />
+, mountNode);一个复杂的应用实例。
import { Calendar } from 'antd';
-
-function onPanelChange(value, mode) {
- console.log(value, mode);
-}
-
-ReactDOM.render(
- <div style={{ width: 290, border: '1px solid #d9d9d9', borderRadius: 4 }}>
- <Calendar fullscreen={false} onPanelChange={onPanelChange} />
- </div>
-, mountNode);import { Calendar } from 'antd';
-
-function dateCellRender(value) {
- return <div>自定义日数据 {value.getDayOfMonth()}</div>;
-}
-
-function monthCellRender(value) {
- return <div>自定义月数据 {value.getMonth()}</div>;
-}
-
-ReactDOM.render(
- <Calendar defaultValue={new Date('2010-10-10')}
- dateCellRender={dateCellRender} monthCellRender={monthCellRender} />
-, mountNode);通过 locale 配置时区、语言等, 默认支持 en_US, zh_CN
import { Calendar } from 'antd';
+
+function onPanelChange(value, mode) {
+ console.log(value, mode);
+}
+
+ReactDOM.render(
+ <div style={{ width: 290, border: '1px solid #d9d9d9', borderRadius: 4 }}>
+ <Calendar fullscreen={false} onPanelChange={onPanelChange} />
+ </div>
+, mountNode);注意: 在表单里面,我们只使用大尺寸, 即高度为 32px,作为唯一的尺寸。
import {Form, Input, Button, Checkbox, message} from 'antd';
+const FormItem = Form.Item;
+
+const Demo = React.createClass({
+ mixins: [Form.ValueMixin],
+
+ getInitialState() {
+ return {
+ formData: {
+ userName: undefined,
+ password: undefined,
+ agreement: undefined,
+ }
+ };
+ },
+
+ handleSubmit(e) {
+ e.preventDefault();
+ message.success('收到表单值~~~ :' + JSON.stringify(this.state.formData, function(k, v) {
+ if (typeof v === 'undefined') {
+ return '';
+ }
+ return v;
+ }));
+ },
+
+ render() {
+ const formData = this.state.formData;
+ return (
+ <Form inline onSubmit={this.handleSubmit}>
+ <FormItem
+ id="userName"
+ label="账户:">
+ <Input placeholder="请输入账户名" id="userName" name="userName" onChange={this.setValue.bind(this, 'userName')} value={formData.userName} />
+ </FormItem>
+ <FormItem
+ id="password"
+ label="密码:">
+ <Input type="password" placeholder="请输入密码" id="password" name="password" onChange={this.setValue.bind(this, 'password')} value={formData.password} />
+ </FormItem>
+ <FormItem>
+ <label className="ant-checkbox-inline">
+ <Checkbox name="agreement" value={formData.agreement} onChange={this.setValue.bind(this, 'agreement')} /> 记住我
+ </label>
+ </FormItem>
+ <Button type="primary" htmlType="submit">登录</Button>
+ </Form>
+ );
+ }
+});
+
+ReactDOM.render(<Demo />, mountNode);mixins;
import {Form, Input, Select, Checkbox, Radio} from 'antd';
+const FormItem = Form.Item;
+const Option = Select.Option;
+const RadioGroup = Radio.Group;
+
+function handleSelectChange(value) {
+ console.log('selected ' + value);
+}
+
+ReactDOM.render(
+ <Form horizontal>
+ <FormItem
+ id="control-input"
+ label="输入框:"
+ labelCol={{span: 6}}
+ wrapperCol={{span: 14}}>
+ <Input id="control-input" placeholder="Please enter..." />
+ </FormItem>
+
+ <FormItem
+ id="control-textarea"
+ label="文本域:"
+ labelCol={{span: 6}}
+ wrapperCol={{span: 14}}>
+ <Input type="textarea" id="control-textarea" rows="3" />
+ </FormItem>
+
+ <FormItem
+ id="select"
+ label="Select 选择器:"
+ labelCol={{span: 6}}
+ wrapperCol={{span: 14}}>
+ <Select id="select" size="large" defaultValue="lucy" style={{width:200}} onChange={handleSelectChange}>
+ <Option value="jack">jack</Option>
+ <Option value="lucy">lucy</Option>
+ <Option value="disabled" disabled>disabled</Option>
+ < Option value="yiminghe">yiminghe</Option>
+ </Select>
+ </FormItem>
+
+ <FormItem
+ label="Checkbox 多选框:"
+ labelCol={{span: 6}}
+ wrapperCol={{span: 18}} >
+ <label className="ant-checkbox-vertical">
+ <Checkbox />选项一
+ </label>
+ <label className="ant-checkbox-vertical">
+ <Checkbox />选项二
+ </label>
+ <label className="ant-checkbox-vertical">
+ <Checkbox disabled />选项三(不可选)
+ </label>
+ </FormItem>
+
+ <FormItem
+ label="Checkbox 多选框:"
+ labelCol={{span: 6}}
+ wrapperCol={{span: 18}} >
+ <label className="ant-checkbox-inline">
+ <Checkbox />选项一
+ </label>
+ <label className="ant-checkbox-inline">
+ <Checkbox />选项二
+ </label>
+ <label className="ant-checkbox-inline">
+ <Checkbox />选项三
+ </label>
+ </FormItem>
+
+ <FormItem
+ label="Radio 单选框:"
+ labelCol={{span: 6}}
+ wrapperCol={{span: 18}} >
+ <RadioGroup value="b">
+ <Radio value="a">A</Radio>
+ <Radio value="b">B</Radio>
+ <Radio value="c">C</Radio>
+ <Radio value="d">D</Radio>
+ </RadioGroup>
+ </FormItem>
+ </Form>
+, mountNode);各类输入框的组合展现。
import { Form, Input, DatePicker, Col } from 'antd';
-const FormItem = Form.Item;
-
-ReactDOM.render(
- <Form horizontal>
- <FormItem
- label="失败校验:"
- labelCol={{span: 5}}
- wrapperCol={{span: 12}}
- validateStatus="error"
- help="请输入数字和字母组合">
- <Input defaultValue="无效选择" id="error" />
- </FormItem>
-
- <FormItem
- label="警告校验:"
- labelCol={{span: 5}}
- wrapperCol={{span: 12}}
- validateStatus="warning">
- <Input defaultValue="前方高能预警" id="warning" />
- </FormItem>
-
- <FormItem
- label="校验中:"
- labelCol={{span: 5}}
- wrapperCol={{span: 12}}
- hasFeedback
- validateStatus="validating"
- help="信息审核中...">
- <Input defaultValue="我是被校验的内容" id="validating" />
- </FormItem>
-
- <FormItem
- label="成功校验:"
- labelCol={{span: 5}}
- wrapperCol={{span: 12}}
- hasFeedback
- validateStatus="success">
- <Input defaultValue="我是正文" id="success" />
- </FormItem>
-
- <FormItem
- label="警告校验:"
- labelCol={{span: 5}}
- wrapperCol={{span: 12}}
- hasFeedback
- validateStatus="warning">
- <Input defaultValue="前方高能预警" id="warning" />
- </FormItem>
-
- <FormItem
- label="失败校验:"
- labelCol={{span: 5}}
- wrapperCol={{span: 12}}
- hasFeedback
- validateStatus="error"
- help="请输入数字和字母组合">
- <Input defaultValue="无效选择" id="error" />
- </FormItem>
-
- <FormItem
- label="Datepicker:"
- labelCol={{span: 5}}
- validateStatus="error">
- <Col span="6">
- <DatePicker />
- </Col>
- <Col span="1">
- <p className="ant-form-split">-</p>
- </Col>
- <Col span="6">
- <DatePicker />
- </Col>
- <Col span="19" offset="5">
- <p className="ant-form-explain">请输入正确选项</p>
- </Col>
- </FormItem>
- </Form>
-, mountNode);import { Form, Input, Row, Col, Button } from 'antd';
-const FormItem = Form.Item;
-
-ReactDOM.render(
-<Form horizontal className="advanced-search-form">
- <Row>
- <Col span="8">
- <FormItem
- label="搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- <FormItem
- label="较长搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- <FormItem
- label="搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- </Col>
- <Col span="8">
- <FormItem
- label="搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- <FormItem
- label="较长搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- <FormItem
- label="搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- </Col>
- <Col span="8">
- <FormItem
- label="搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- <FormItem
- label="较长搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- <FormItem
- label="搜索名称:"
- labelCol={{span: 10}}
- wrapperCol={{span: 14}}>
- <Input placeholder="请输入搜索名称" />
- </FormItem>
- </Col>
- </Row>
- <Row>
- <Col span="8" offset="16" style={{textAlign: 'right'}}>
- <Button type="primary" htmlType="submit">搜索</Button>
- <Button type="ghost">清除条件</Button>
- </Col>
- </Row>
-</Form>
-, mountNode);/* 定制样式 */
-
-.advanced-search-form {
- padding: 16px 8px;
- background: #f8f8f8;
- border: 1px solid #d9d9d9;
- border-radius: 6px;
-}
-
-/* 由于输入标签长度不确定,所以需要微调使之看上去居中 */
-.advanced-search-form > .row {
- margin-left: -10px;
-}
-
-.advanced-search-form > .row > .col-8 {
- padding: 0 8px;
-}
-
-.advanced-search-form .ant-form-item {
- margin-bottom: 16px;
-}
-
-.advanced-search-form .ant-btn + .ant-btn {
- margin-left: 8px;
-}import {Form, Input, Button, Checkbox, message} from 'antd';
-const FormItem = Form.Item;
-
-const Demo = React.createClass({
- mixins: [Form.ValueMixin],
-
- getInitialState() {
- return {
- formData: {
- userName: undefined,
- password: undefined,
- agreement: undefined,
- }
- };
- },
-
- handleSubmit(e) {
- e.preventDefault();
- message.success('收到表单值~~~ :' + JSON.stringify(this.state.formData, function(k, v) {
- if (typeof v === 'undefined') {
- return '';
- }
- return v;
- }));
- },
-
- render() {
- const formData = this.state.formData;
- return (
- <Form inline onSubmit={this.handleSubmit}>
- <FormItem
- id="userName"
- label="账户:">
- <Input placeholder="请输入账户名" id="userName" name="userName" onChange={this.setValue.bind(this, 'userName')} value={formData.userName} />
- </FormItem>
- <FormItem
- id="password"
- label="密码:">
- <Input type="password" placeholder="请输入密码" id="password" name="password" onChange={this.setValue.bind(this, 'password')} value={formData.password} />
- </FormItem>
- <FormItem>
- <label className="ant-checkbox-inline">
- <Checkbox name="agreement" value={formData.agreement} onChange={this.setValue.bind(this, 'agreement')} /> 记住我
- </label>
- </FormItem>
- <Button type="primary" htmlType="submit">登录</Button>
- </Form>
- );
- }
-});
-
-ReactDOM.render(<Demo />, mountNode);import {Form, Input, Select, Checkbox, Radio} from 'antd';
-const FormItem = Form.Item;
-const Option = Select.Option;
-const RadioGroup = Radio.Group;
-
-function handleSelectChange(value) {
- console.log('selected ' + value);
-}
-
-ReactDOM.render(
- <Form horizontal>
- <FormItem
- id="control-input"
- label="输入框:"
- labelCol={{span: 6}}
- wrapperCol={{span: 14}}>
- <Input id="control-input" placeholder="Please enter..." />
- </FormItem>
-
- <FormItem
- id="control-textarea"
- label="文本域:"
- labelCol={{span: 6}}
- wrapperCol={{span: 14}}>
- <Input type="textarea" id="control-textarea" rows="3" />
- </FormItem>
-
- <FormItem
- id="select"
- label="Select 选择器:"
- labelCol={{span: 6}}
- wrapperCol={{span: 14}}>
- <Select id="select" size="large" defaultValue="lucy" style={{width:200}} onChange={handleSelectChange}>
- <Option value="jack">jack</Option>
- <Option value="lucy">lucy</Option>
- <Option value="disabled" disabled>disabled</Option>
- < Option value="yiminghe">yiminghe</Option>
- </Select>
- </FormItem>
-
- <FormItem
- label="Checkbox 多选框:"
- labelCol={{span: 6}}
- wrapperCol={{span: 18}} >
- <label className="ant-checkbox-vertical">
- <Checkbox />选项一
- </label>
- <label className="ant-checkbox-vertical">
- <Checkbox />选项二
- </label>
- <label className="ant-checkbox-vertical">
- <Checkbox disabled />选项三(不可选)
- </label>
- </FormItem>
-
- <FormItem
- label="Checkbox 多选框:"
- labelCol={{span: 6}}
- wrapperCol={{span: 18}} >
- <label className="ant-checkbox-inline">
- <Checkbox />选项一
- </label>
- <label className="ant-checkbox-inline">
- <Checkbox />选项二
- </label>
- <label className="ant-checkbox-inline">
- <Checkbox />选项三
- </label>
- </FormItem>
-
- <FormItem
- label="Radio 单选框:"
- labelCol={{span: 6}}
- wrapperCol={{span: 18}} >
- <RadioGroup value="b">
- <Radio value="a">A</Radio>
- <Radio value="b">B</Radio>
- <Radio value="c">C</Radio>
- <Radio value="d">D</Radio>
- </RadioGroup>
- </FormItem>
- </Form>
-, mountNode);import { Form, Input, DatePicker, Col } from 'antd';
+const FormItem = Form.Item;
+
+ReactDOM.render(
+ <Form horizontal>
+ <FormItem
+ label="失败校验:"
+ labelCol={{span: 5}}
+ wrapperCol={{span: 12}}
+ validateStatus="error"
+ help="请输入数字和字母组合">
+ <Input defaultValue="无效选择" id="error" />
+ </FormItem>
+
+ <FormItem
+ label="警告校验:"
+ labelCol={{span: 5}}
+ wrapperCol={{span: 12}}
+ validateStatus="warning">
+ <Input defaultValue="前方高能预警" id="warning" />
+ </FormItem>
+
+ <FormItem
+ label="校验中:"
+ labelCol={{span: 5}}
+ wrapperCol={{span: 12}}
+ hasFeedback
+ validateStatus="validating"
+ help="信息审核中...">
+ <Input defaultValue="我是被校验的内容" id="validating" />
+ </FormItem>
+
+ <FormItem
+ label="成功校验:"
+ labelCol={{span: 5}}
+ wrapperCol={{span: 12}}
+ hasFeedback
+ validateStatus="success">
+ <Input defaultValue="我是正文" id="success" />
+ </FormItem>
+
+ <FormItem
+ label="警告校验:"
+ labelCol={{span: 5}}
+ wrapperCol={{span: 12}}
+ hasFeedback
+ validateStatus="warning">
+ <Input defaultValue="前方高能预警" id="warning" />
+ </FormItem>
+
+ <FormItem
+ label="失败校验:"
+ labelCol={{span: 5}}
+ wrapperCol={{span: 12}}
+ hasFeedback
+ validateStatus="error"
+ help="请输入数字和字母组合">
+ <Input defaultValue="无效选择" id="error" />
+ </FormItem>
+
+ <FormItem
+ label="Datepicker:"
+ labelCol={{span: 5}}
+ validateStatus="error">
+ <Col span="6">
+ <DatePicker />
+ </Col>
+ <Col span="1">
+ <p className="ant-form-split">-</p>
+ </Col>
+ <Col span="6">
+ <DatePicker />
+ </Col>
+ <Col span="19" offset="5">
+ <p className="ant-form-explain">请输入正确选项</p>
+ </Col>
+ </FormItem>
+ </Form>
+, mountNode);2) 为 <fieldset> 设置 disabled 属性,可以禁用 <fieldset> 中包含的所有控件。
import { Form, Input, Row, Col, Button } from 'antd';
+const FormItem = Form.Item;
+
+ReactDOM.render(
+<Form horizontal className="advanced-search-form">
+ <Row>
+ <Col span="8">
+ <FormItem
+ label="搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ <FormItem
+ label="较长搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ <FormItem
+ label="搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ </Col>
+ <Col span="8">
+ <FormItem
+ label="搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ <FormItem
+ label="较长搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ <FormItem
+ label="搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ </Col>
+ <Col span="8">
+ <FormItem
+ label="搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ <FormItem
+ label="较长搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ <FormItem
+ label="搜索名称:"
+ labelCol={{span: 10}}
+ wrapperCol={{span: 14}}>
+ <Input placeholder="请输入搜索名称" />
+ </FormItem>
+ </Col>
+ </Row>
+ <Row>
+ <Col span="8" offset="16" style={{textAlign: 'right'}}>
+ <Button type="primary" htmlType="submit">搜索</Button>
+ <Button type="ghost">清除条件</Button>
+ </Col>
+ </Row>
+</Form>
+, mountNode);/* 定制样式 */
+
+.advanced-search-form {
+ padding: 16px 8px;
+ background: #f8f8f8;
+ border: 1px solid #d9d9d9;
+ border-radius: 6px;
+}
+
+/* 由于输入标签长度不确定,所以需要微调使之看上去居中 */
+.advanced-search-form > .row {
+ margin-left: -10px;
+}
+
+.advanced-search-form > .row > .col-8 {
+ padding: 0 8px;
+}
+
+.advanced-search-form .ant-form-item {
+ margin-bottom: 16px;
+}
+
+.advanced-search-form .ant-btn + .ant-btn {
+ margin-left: 8px;
+}使用单一的一组 .col-* 栅格类,就可以创建一个基本的栅格系统,所有列(column)必须放在 .row 内。
import { Row, Col } from 'antd';
-
-ReactDOM.render(
- <div>
- <Row>
- <Col span="18" push="6">.col-18 .col-push-6</Col>
- <Col span="6" pull="18">.col-6 .col-pull-18</Col>
- </Row>
- </div>,
- mountNode
-);import { Row, Col } from 'antd';
-
-const DemoBox = React.createClass({
- render() {
- const { value } = this.props;
- const className = `hight-${value}`;
- return (
- <p className={className}>{this.props.children}</p>
- );
- }
-});
-
-ReactDOM.render(
- <div>
- <p>顶部对齐</p>
- <Row type="flex" justify="center" align="top">
- <Col span="4"><DemoBox value="100">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="50">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="120">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="80">.col-4</DemoBox></Col>
- </Row>
-
- <p>居中对齐</p>
- <Row type="flex" justify="space-around" align="middle">
- <Col span="4"><DemoBox value="100">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="50">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="120">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="80">.col-4</DemoBox></Col>
- </Row>
-
- <p>底部对齐</p>
- <Row type="flex" justify="space-between" align="bottom">
- <Col span="4"><DemoBox value="100">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="50">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="120">.col-4</DemoBox></Col>
- <Col span="4"><DemoBox value="80">.col-4</DemoBox></Col>
- </Row>
- </div>,
- mountNode
-);使用 .col-offset-* 类可以将列向右侧偏。例如,.col-offset-4 类将 .col-4 元素向右侧偏移了4个列(column)的宽度。
import { Row, Col } from 'antd';
+
+ReactDOM.render(
+ <div>
+ <Row>
+ <Col span="18" push="6">.col-18 .col-push-6</Col>
+ <Col span="6" pull="18">.col-6 .col-pull-18</Col>
+ </Row>
+ </div>,
+ mountNode
+);使用 row-flex 定义 flex 布局,其子元素根据不同的值 start,center,end,space-between,space-around,分别定义其在父节点里面的排版方式。
import { Row, Col } from 'antd';
+
+const DemoBox = React.createClass({
+ render() {
+ const { value } = this.props;
+ const className = `hight-${value}`;
+ return (
+ <p className={className}>{this.props.children}</p>
+ );
+ }
+});
+
+ReactDOM.render(
+ <div>
+ <p>顶部对齐</p>
+ <Row type="flex" justify="center" align="top">
+ <Col span="4"><DemoBox value="100">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="50">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="120">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="80">.col-4</DemoBox></Col>
+ </Row>
+
+ <p>居中对齐</p>
+ <Row type="flex" justify="space-around" align="middle">
+ <Col span="4"><DemoBox value="100">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="50">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="120">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="80">.col-4</DemoBox></Col>
+ </Row>
+
+ <p>底部对齐</p>
+ <Row type="flex" justify="space-between" align="bottom">
+ <Col span="4"><DemoBox value="100">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="50">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="120">.col-4</DemoBox></Col>
+ <Col span="4"><DemoBox value="80">.col-4</DemoBox></Col>
+ </Row>
+ </div>,
+ mountNode
+);import { Menu, Icon } from 'antd';
+const SubMenu = Menu.SubMenu;
+const MenuItemGroup = Menu.ItemGroup;
+
+const Sider = React.createClass({
+ getInitialState() {
+ return {
+ current: '1'
+ };
+ },
+ handleClick(e) {
+ console.log('click ', e);
+ this.setState({
+ current: e.key
+ });
+ },
+ render() {
+ return <Menu onClick={this.handleClick}
+ style={{width:240}}
+ defaultOpenKeys={['sub1']}
+ selectedKeys={[this.state.current]}
+ mode="inline">
+ <SubMenu key="sub1" title={<span><Icon type="mail" /><span>导航一</span></span>}>
+ <MenuItemGroup title="分组1">
+ <Menu.Item key="1">选项1</Menu.Item>
+ <Menu.Item key="2">选项2</Menu.Item>
+ </MenuItemGroup>
+ <MenuItemGroup title="分组2">
+ <Menu.Item key="3">选项3</Menu.Item>
+ <Menu.Item key="4">选项4</Menu.Item>
+ </MenuItemGroup>
+ </SubMenu>
+ <SubMenu key="sub2" title={<span><Icon type="appstore" /><span>导航二</span></span>}>
+ <Menu.Item key="5">选项5</Menu.Item>
+ <Menu.Item key="6">选项6</Menu.Item>
+ <SubMenu key="sub3" title="三级导航">
+ <Menu.Item key="7">选项7</Menu.Item>
+ <Menu.Item key="8">选项8</Menu.Item>
+ </SubMenu>
+ </SubMenu>
+ <SubMenu key="sub4" title={<span><Icon type="setting" /><span>导航三</span></span>}>
+ <Menu.Item key="9">选项9</Menu.Item>
+ <Menu.Item key="10">选项10</Menu.Item>
+ <Menu.Item key="11">选项11</Menu.Item>
+ <Menu.Item key="12">选项12</Menu.Item>
+ </SubMenu>
+ </Menu>;
+ }
+});
+ReactDOM.render(<Sider />, mountNode);import { Menu, Icon } from 'antd';
+const SubMenu = Menu.SubMenu;
+const MenuItemGroup = Menu.ItemGroup;
+
+function handleClick(e) {
+ console.log('click', e);
+}
+
+ReactDOM.render(<Menu onClick={handleClick} style={{width:240}} mode="vertical">
+ <SubMenu key="sub1" title={<span><Icon type="mail" /><span>导航一</span></span>}>
+ <MenuItemGroup title="分组1">
+ <Menu.Item key="1">选项1</Menu.Item>
+ <Menu.Item key="2">选项2</Menu.Item>
+ </MenuItemGroup>
+ <MenuItemGroup title="分组2">
+ <Menu.Item key="3">选项3</Menu.Item>
+ <Menu.Item key="4">选项4</Menu.Item>
+ </MenuItemGroup>
+ </SubMenu>
+ <SubMenu key="sub2" title={<span><Icon type="appstore" /><span>导航二</span></span>}>
+ <Menu.Item key="5">选项5</Menu.Item>
+ <Menu.Item key="6">选项6</Menu.Item>
+ <SubMenu key="sub3" title="三级导航">
+ <Menu.Item key="7">选项7</Menu.Item>
+ <Menu.Item key="8">选项8</Menu.Item>
+ </SubMenu>
+ </SubMenu>
+ <SubMenu key="sub4" title={<span><icon type="setting" /><span>导航三</span></span>}>
+ <Menu.Item key="9">选项9</Menu.Item>
+ <Menu.Item key="10">选项10</Menu.Item>
+ <Menu.Item key="11">选项11</Menu.Item>
+ <Menu.Item key="12">选项12</Menu.Item>
+ </SubMenu>
+</Menu>
+, mountNode);import { Menu, Icon } from 'antd';
-const SubMenu = Menu.SubMenu;
-const MenuItemGroup = Menu.ItemGroup;
-
-const Sider = React.createClass({
- getInitialState() {
- return {
- current: '1'
- };
- },
- handleClick(e) {
- console.log('click ', e);
- this.setState({
- current: e.key
- });
- },
- render() {
- return <Menu onClick={this.handleClick}
- style={{width:240}}
- defaultOpenKeys={['sub1']}
- selectedKeys={[this.state.current]}
- mode="inline">
- <SubMenu key="sub1" title={<span><Icon type="mail" /><span>导航一</span></span>}>
- <MenuItemGroup title="分组1">
- <Menu.Item key="1">选项1</Menu.Item>
- <Menu.Item key="2">选项2</Menu.Item>
- </MenuItemGroup>
- <MenuItemGroup title="分组2">
- <Menu.Item key="3">选项3</Menu.Item>
- <Menu.Item key="4">选项4</Menu.Item>
- </MenuItemGroup>
- </SubMenu>
- <SubMenu key="sub2" title={<span><Icon type="appstore" /><span>导航二</span></span>}>
- <Menu.Item key="5">选项5</Menu.Item>
- <Menu.Item key="6">选项6</Menu.Item>
- <SubMenu key="sub3" title="三级导航">
- <Menu.Item key="7">选项7</Menu.Item>
- <Menu.Item key="8">选项8</Menu.Item>
- </SubMenu>
- </SubMenu>
- <SubMenu key="sub4" title={<span><Icon type="setting" /><span>导航三</span></span>}>
- <Menu.Item key="9">选项9</Menu.Item>
- <Menu.Item key="10">选项10</Menu.Item>
- <Menu.Item key="11">选项11</Menu.Item>
- <Menu.Item key="12">选项12</Menu.Item>
- </SubMenu>
- </Menu>;
- }
-});
-ReactDOM.render(<Sider />, mountNode);import { Menu, Icon } from 'antd';
-const SubMenu = Menu.SubMenu;
-const MenuItemGroup = Menu.ItemGroup;
-
-function handleClick(e) {
- console.log('click', e);
-}
-
-ReactDOM.render(<Menu onClick={handleClick} style={{width:240}} mode="vertical">
- <SubMenu key="sub1" title={<span><Icon type="mail" /><span>导航一</span></span>}>
- <MenuItemGroup title="分组1">
- <Menu.Item key="1">选项1</Menu.Item>
- <Menu.Item key="2">选项2</Menu.Item>
- </MenuItemGroup>
- <MenuItemGroup title="分组2">
- <Menu.Item key="3">选项3</Menu.Item>
- <Menu.Item key="4">选项4</Menu.Item>
- </MenuItemGroup>
- </SubMenu>
- <SubMenu key="sub2" title={<span><Icon type="appstore" /><span>导航二</span></span>}>
- <Menu.Item key="5">选项5</Menu.Item>
- <Menu.Item key="6">选项6</Menu.Item>
- <SubMenu key="sub3" title="三级导航">
- <Menu.Item key="7">选项7</Menu.Item>
- <Menu.Item key="8">选项8</Menu.Item>
- </SubMenu>
- </SubMenu>
- <SubMenu key="sub4" title={<span><icon type="setting" /><span>导航三</span></span>}>
- <Menu.Item key="9">选项9</Menu.Item>
- <Menu.Item key="10">选项10</Menu.Item>
- <Menu.Item key="11">选项11</Menu.Item>
- <Menu.Item key="12">选项12</Menu.Item>
- </SubMenu>
-</Menu>
-, mountNode);Tooltip 内容
-
- Tooltip 内容
+
+ import { Steps } from 'antd';
-const Step = Steps.Step;
-
-ReactDOM.render(<Steps>
- <Step status="finish" title="步骤1" icon="cloud" />
- <Step status="process" title="步骤2" icon="apple" />
- <Step status="wait" title="步骤3" icon="github" />
-</Steps>, mountNode);import { Steps } from 'antd';
-const Step = Steps.Step;
-
-const steps = [{
- title: '已完成',
- description: '这里是信息的描述'
-}, {
- title: '进行中',
- description: '这里是信息的描述'
-}, {
- title: '待运行',
- description: '这里是信息的描述'
-}, {
- title: '又一个待运行',
- description: '这里是信息的描述'
-}].map(function(s, i) {
- return (
- <Step key={i} title={s.title} description={s.description} />
- );
-});
-
-ReactDOM.render(<Steps direction="vertical" current={1}>{steps}</Steps>,
- mountNode);import { Steps } from 'antd';
-const Step = Steps.Step;
-
-const steps = [{
- status: 'finish',
- title: '已完成',
- description: '这里是多信息的描述啊'
-}, {
- status: 'process',
- title: '进行中',
- description: '这里是多信息的耶哦耶哦哦耶哦耶'
-}, {
- status: 'wait',
- title: '又一个待运行',
- description: '描述啊描述啊'
-}, {
- status: 'wait',
- title: '待运行',
- description: '这里是多信息的描述啊'
-}].map(function(s, i) {
- return (
- <Step key={i} title={s.title} status={s.status} description={s.description} />
- );
-});
-
-ReactDOM.render(<Steps>{steps}</Steps>, mountNode);import { Steps } from 'antd';
+const Step = Steps.Step;
+
+ReactDOM.render(<Steps>
+ <Step status="finish" title="步骤1" icon="cloud" />
+ <Step status="process" title="步骤2" icon="apple" />
+ <Step status="wait" title="步骤3" icon="github" />
+</Steps>, mountNode);随机生成 3~6 个步骤,初始随机进行到其中一个步骤。
import { Steps } from 'antd';
+const Step = Steps.Step;
+
+const steps = [{
+ title: '已完成',
+ description: '这里是信息的描述'
+}, {
+ title: '进行中',
+ description: '这里是信息的描述'
+}, {
+ title: '待运行',
+ description: '这里是信息的描述'
+}, {
+ title: '又一个待运行',
+ description: '这里是信息的描述'
+}].map(function(s, i) {
+ return (
+ <Step key={i} title={s.title} description={s.description} />
+ );
+});
+
+ReactDOM.render(<Steps direction="vertical" current={1}>{steps}</Steps>,
+ mountNode);import { Steps } from 'antd';
+const Step = Steps.Step;
+
+const steps = [{
+ status: 'finish',
+ title: '已完成',
+ description: '这里是多信息的描述啊'
+}, {
+ status: 'process',
+ title: '进行中',
+ description: '这里是多信息的耶哦耶哦哦耶哦耶'
+}, {
+ status: 'wait',
+ title: '又一个待运行',
+ description: '描述啊描述啊'
+}, {
+ status: 'wait',
+ title: '待运行',
+ description: '这里是多信息的描述啊'
+}].map(function(s, i) {
+ return (
+ <Step key={i} title={s.title} status={s.status} description={s.description} />
+ );
+});
+
+ReactDOM.render(<Steps>{steps}</Steps>, mountNode);import { Table } from 'antd';
+
+const columns = [{
+ title: '姓名',
+ dataIndex: 'name',
+ render: function(text) {
+ return <a href="#">{text}</a>;
+ }
+}, {
+ title: '年龄',
+ dataIndex: 'age'
+}, {
+ title: '住址',
+ dataIndex: 'address'
+}];
+const data = [{
+ key: '1',
+ name: '胡彦斌',
+ age: 32,
+ address: '西湖区湖底公园1号'
+}, {
+ key: '2',
+ name: '胡彦祖',
+ age: 42,
+ address: '西湖区湖底公园1号'
+}, {
+ key: '3',
+ name: '李大嘴',
+ age: 32,
+ address: '西湖区湖底公园1号'
+}];
+
+// 通过 rowSelection 对象表明需要行选择
+const rowSelection = {
+ onChange(selectedRowKeys) {
+ console.log('selectedRowKeys changed: ' + selectedRowKeys);
+ },
+ onSelect: function(record, selected, selectedRows) {
+ console.log(record, selected, selectedRows);
+ },
+ onSelectAll: function(selected, selectedRows) {
+ console.log(selected, selectedRows);
+ }
+};
+
+ReactDOM.render(<Table rowSelection={rowSelection} columns={columns} dataSource={data} />
+, mountNode);import { Table } from 'antd';
+
+const columns = [{
+ title: '姓名',
+ dataIndex: 'name',
+ render: function(text) {
+ return <a href="#">{text}</a>;
+ }
+}, {
+ title: '年龄',
+ dataIndex: 'age'
+}, {
+ title: '住址',
+ dataIndex: 'address'
+}];
+const data = [{
+ key: '1',
+ name: '胡彦斌',
+ age: 32,
+ address: '西湖区湖底公园1号'
+}, {
+ key: '2',
+ name: '胡彦祖',
+ age: 42,
+ address: '西湖区湖底公园1号'
+}, {
+ key: '3',
+ name: '李大嘴',
+ age: 32,
+ address: '西湖区湖底公园1号'
+}];
+
+// 通过 rowSelection 对象表明需要行选择
+const rowSelection = {
+ getCheckboxProps: function(record) {
+ return {
+ defaultChecked: record.name === '李大嘴', // 配置默认勾选的列
+ disabled: record.name === '胡彦祖' // 配置无法勾选的列
+ };
+ },
+ onChange(selectedRowKeys) {
+ console.log('selectedRowKeys changed: ' + selectedRowKeys);
+ },
+ onSelect: function(record, selected, selectedRows) {
+ console.log(record, selected, selectedRows);
+ },
+ onSelectAll: function(selected, selectedRows) {
+ console.log(selected, selectedRows);
+ },
+};
+
+ReactDOM.render(<Table rowSelection={rowSelection} columns={columns} dataSource={data} />
+, mountNode);import { Table } from 'antd';
+
+const columns = [{
+ title: '姓名',
+ dataIndex: 'name',
+ filters: [{
+ text: '姓李的',
+ value: '李'
+ }, {
+ text: '姓胡的',
+ value: '胡'
+ }],
+ // 指定确定筛选的条件函数
+ // 这里是名字中第一个字是 value
+ onFilter: function(value, record) {
+ return record.name.indexOf(value) === 0;
+ },
+ sorter: function(a, b) {
+ return a.name.length - b.name.length;
+ }
+}, {
+ title: '年龄',
+ dataIndex: 'age',
+ sorter: function(a, b) {
+ return a.age - b.age;
+ }
+}, {
+ title: '地址',
+ dataIndex: 'address',
+ filters: [{
+ text: '南湖',
+ value: '南湖'
+ }, {
+ text: '西湖',
+ value: '西湖'
+ }],
+ filterMultiple: false,
+ onFilter: function(value, record) {
+ return record.address.indexOf(value) === 0;
+ },
+ sorter: function(a, b) {
+ return a.address.length - b.address.length;
+ }
+}];
+
+const data = [{
+ key: '1',
+ name: '胡斌',
+ age: 32,
+ address: '南湖区湖底公园1号'
+}, {
+ key: '2',
+ name: '胡彦祖',
+ age: 42,
+ address: '西湖区湖底公园12号'
+}, {
+ key: '3',
+ name: '李大嘴',
+ age: 32,
+ address: '南湖区湖底公园123号'
+}, {
+ key: '4',
+ name: '李秀莲大嘴哥',
+ age: 32,
+ address: '西湖区湖底公园123号'
+}];
+
+function onChange(pagination, filters, sorter) {
+ // 点击分页、筛选、排序时触发
+ console.log('各类参数是', pagination, filters, sorter);
+}
+
+ReactDOM.render(<Table columns={columns} dataSource={data} onChange={onChange} />
+, mountNode);import { Table } from 'antd';
+
+const columns = [{
+ title: '姓名',
+ dataIndex: 'name'
+}, {
+ title: '年龄',
+ dataIndex: 'age'
+}, {
+ title: '住址',
+ dataIndex: 'address'
+}];
+
+const data = [{
+ key: '1',
+ name: '胡彦斌',
+ age: 32,
+ address: '西湖区湖底公园1号'
+}, {
+ key: '2',
+ name: '胡彦祖',
+ age: 42,
+ address: '西湖区湖底公园1号'
+}, {
+ key: '3',
+ name: '李大嘴',
+ age: 32,
+ address: '西湖区湖底公园1号'
+}];
+
+ReactDOM.render(<Table columns={columns} dataSource={data} pagination={false} />
+, mountNode);import { Table } from 'antd';
-
-function renderAction() {
- return <a href="#">删除</a>;
-}
-
-function expandedRowRender(record) {
- return <p>{record.description}</p>;
-}
-
-const columns = [
- {title: '姓名', dataIndex: 'name', key: 'name'},
- {title: '年龄', dataIndex: 'age', key: 'age'},
- {title: '住址', dataIndex: 'address', key: 'address'},
- {title: '操作', dataIndex: '', key: 'x', render: renderAction}
-];
-
-const data = [
- {key: 1, name: '胡彦斌', age: 32, address: '西湖区湖底公园1号', description: '我是胡彦斌,今年32岁,住在西湖区湖底公园1号。'},
- {key: 2, name: '吴彦祖', age: 42, address: '西湖区湖底公园2号', description: '我是吴彦祖,今年42岁,住在西湖区湖底公园2号。'},
- {key: 3, name: '李大嘴', age: 32, address: '西湖区湖底公园3号', description: '我是李大嘴,今年32岁,住在西湖区湖底公园3号。'}
-];
-
-ReactDOM.render(
-<Table columns={columns}
- expandedRowRender={expandedRowRender}
- dataSource={data}
- className="table" />
-, mountNode);import { Table, Button } from 'antd';
-
-const columns = [{
- title: '姓名',
- dataIndex: 'name'
-}, {
- title: '年龄',
- dataIndex: 'age'
-}, {
- title: '住址',
- dataIndex: 'address'
-}];
-const data = [{
- key: '1',
- name: '胡彦斌',
- age: 32,
- address: '西湖区湖底公园1号'
-}, {
- key: '2',
- name: '胡彦祖',
- age: 42,
- address: '西湖区湖底公园1号'
-}, {
- key: '3',
- name: '李大嘴',
- age: 32,
- address: '西湖区湖底公园1号'
-}];
-
-const App = React.createClass({
- getInitialState() {
- return {
- loading: false
- };
- },
- toggleLoading() {
- this.setState({
- loading: !this.state.loading
- });
- },
- render() {
- return <div>
- <Table columns={columns} dataSource={data} loading={this.state.loading} />
- <Button type="primary" onClick={this.toggleLoading}>切换 loading 状态</Button>
- </div>;
- }
-});
-
-ReactDOM.render(<App />, mountNode);import { Table } from 'antd';
-
-const columns = [{
- title: '姓名',
- dataIndex: 'name',
- render: function(text) {
- return <a href="#">{text}</a>;
- }
-}, {
- title: '年龄',
- dataIndex: 'age'
-}, {
- title: '住址',
- dataIndex: 'address'
-}];
-const data = [{
- key: '1',
- name: '胡彦斌',
- age: 32,
- address: '西湖区湖底公园1号'
-}, {
- key: '2',
- name: '胡彦祖',
- age: 42,
- address: '西湖区湖底公园1号'
-}, {
- key: '3',
- name: '李大嘴',
- age: 32,
- address: '西湖区湖底公园1号'
-}];
-
-// 通过 rowSelection 对象表明需要行选择
-const rowSelection = {
- onChange(selectedRowKeys) {
- console.log('selectedRowKeys changed: ' + selectedRowKeys);
- },
- onSelect: function(record, selected, selectedRows) {
- console.log(record, selected, selectedRows);
- },
- onSelectAll: function(selected, selectedRows) {
- console.log(selected, selectedRows);
- }
-};
-
-ReactDOM.render(<Table rowSelection={rowSelection} columns={columns} dataSource={data} />
-, mountNode);import { Table } from 'antd';
-
-const columns = [{
- title: '姓名',
- dataIndex: 'name',
- render: function(text) {
- return <a href="#">{text}</a>;
- }
-}, {
- title: '年龄',
- dataIndex: 'age'
-}, {
- title: '住址',
- dataIndex: 'address'
-}];
-const data = [{
- key: '1',
- name: '胡彦斌',
- age: 32,
- address: '西湖区湖底公园1号'
-}, {
- key: '2',
- name: '胡彦祖',
- age: 42,
- address: '西湖区湖底公园1号'
-}, {
- key: '3',
- name: '李大嘴',
- age: 32,
- address: '西湖区湖底公园1号'
-}];
-
-// 通过 rowSelection 对象表明需要行选择
-const rowSelection = {
- getCheckboxProps: function(record) {
- return {
- defaultChecked: record.name === '李大嘴', // 配置默认勾选的列
- disabled: record.name === '胡彦祖' // 配置无法勾选的列
- };
- },
- onChange(selectedRowKeys) {
- console.log('selectedRowKeys changed: ' + selectedRowKeys);
- },
- onSelect: function(record, selected, selectedRows) {
- console.log(record, selected, selectedRows);
- },
- onSelectAll: function(selected, selectedRows) {
- console.log(selected, selectedRows);
- },
-};
-
-ReactDOM.render(<Table rowSelection={rowSelection} columns={columns} dataSource={data} />
-, mountNode);import { Table } from 'antd';
-
-const columns = [{
- title: '姓名',
- dataIndex: 'name',
- filters: [{
- text: '姓李的',
- value: '李'
- }, {
- text: '姓胡的',
- value: '胡'
- }],
- // 指定确定筛选的条件函数
- // 这里是名字中第一个字是 value
- onFilter: function(value, record) {
- return record.name.indexOf(value) === 0;
- },
- sorter: function(a, b) {
- return a.name.length - b.name.length;
- }
-}, {
- title: '年龄',
- dataIndex: 'age',
- sorter: function(a, b) {
- return a.age - b.age;
- }
-}, {
- title: '地址',
- dataIndex: 'address',
- filters: [{
- text: '南湖',
- value: '南湖'
- }, {
- text: '西湖',
- value: '西湖'
- }],
- filterMultiple: false,
- onFilter: function(value, record) {
- return record.address.indexOf(value) === 0;
- },
- sorter: function(a, b) {
- return a.address.length - b.address.length;
- }
-}];
-
-const data = [{
- key: '1',
- name: '胡斌',
- age: 32,
- address: '南湖区湖底公园1号'
-}, {
- key: '2',
- name: '胡彦祖',
- age: 42,
- address: '西湖区湖底公园12号'
-}, {
- key: '3',
- name: '李大嘴',
- age: 32,
- address: '南湖区湖底公园123号'
-}, {
- key: '4',
- name: '李秀莲大嘴哥',
- age: 32,
- address: '西湖区湖底公园123号'
-}];
-
-function onChange(pagination, filters, sorter) {
- // 点击分页、筛选、排序时触发
- console.log('各类参数是', pagination, filters, sorter);
-}
-
-ReactDOM.render(<Table columns={columns} dataSource={data} onChange={onChange} />
-, mountNode);import { Table } from 'antd';
-
-const columns = [{
- title: '姓名',
- dataIndex: 'name'
-}, {
- title: '年龄',
- dataIndex: 'age'
-}, {
- title: '住址',
- dataIndex: 'address'
-}];
-
-const data = [{
- key: '1',
- name: '胡彦斌',
- age: 32,
- address: '西湖区湖底公园1号'
-}, {
- key: '2',
- name: '胡彦祖',
- age: 42,
- address: '西湖区湖底公园1号'
-}, {
- key: '3',
- name: '李大嘴',
- age: 32,
- address: '西湖区湖底公园1号'
-}];
-
-ReactDOM.render(<Table columns={columns} dataSource={data} pagination={false} />
-, mountNode);import { Table } from 'antd';
+
+function renderAction() {
+ return <a href="#">删除</a>;
+}
+
+function expandedRowRender(record) {
+ return <p>{record.description}</p>;
+}
+
+const columns = [
+ {title: '姓名', dataIndex: 'name', key: 'name'},
+ {title: '年龄', dataIndex: 'age', key: 'age'},
+ {title: '住址', dataIndex: 'address', key: 'address'},
+ {title: '操作', dataIndex: '', key: 'x', render: renderAction}
+];
+
+const data = [
+ {key: 1, name: '胡彦斌', age: 32, address: '西湖区湖底公园1号', description: '我是胡彦斌,今年32岁,住在西湖区湖底公园1号。'},
+ {key: 2, name: '吴彦祖', age: 42, address: '西湖区湖底公园2号', description: '我是吴彦祖,今年42岁,住在西湖区湖底公园2号。'},
+ {key: 3, name: '李大嘴', age: 32, address: '西湖区湖底公园3号', description: '我是李大嘴,今年32岁,住在西湖区湖底公园3号。'}
+];
+
+ReactDOM.render(
+<Table columns={columns}
+ expandedRowRender={expandedRowRender}
+ dataSource={data}
+ className="table" />
+, mountNode);表格支持行/列合并,使用 render 里的单元格属性 colSpan 或者 rowSpan 设值为 0 时,设置的表格不会渲染。
import { Table, Button } from 'antd';
+
+const columns = [{
+ title: '姓名',
+ dataIndex: 'name'
+}, {
+ title: '年龄',
+ dataIndex: 'age'
+}, {
+ title: '住址',
+ dataIndex: 'address'
+}];
+const data = [{
+ key: '1',
+ name: '胡彦斌',
+ age: 32,
+ address: '西湖区湖底公园1号'
+}, {
+ key: '2',
+ name: '胡彦祖',
+ age: 42,
+ address: '西湖区湖底公园1号'
+}, {
+ key: '3',
+ name: '李大嘴',
+ age: 32,
+ address: '西湖区湖底公园1号'
+}];
+
+const App = React.createClass({
+ getInitialState() {
+ return {
+ loading: false
+ };
+ },
+ toggleLoading() {
+ this.setState({
+ loading: !this.state.loading
+ });
+ },
+ render() {
+ return <div>
+ <Table columns={columns} dataSource={data} loading={this.state.loading} />
+ <Button type="primary" onClick={this.toggleLoading}>切换 loading 状态</Button>
+ </div>;
+ }
+});
+
+ReactDOM.render(<App />, mountNode);import { Transfer } from 'antd';
+
+const App = React.createClass({
+ getInitialState() {
+ return {
+ mockData: [],
+ targetKeys: [],
+ };
+ },
+ componentDidMount() {
+ this.getMock();
+ },
+ getMock() {
+ let targetKeys = [];
+ let mockData = [];
+ for (let i = 0; i < 20; i++) {
+ const data = {
+ key: i,
+ title: '内容' + (i + 1),
+ description: '内容' + (i + 1) + '的描述',
+ chosen: Math.random() * 2 > 1
+ };
+ if (data.chosen) {
+ targetKeys.push(data.key);
+ }
+ mockData.push(data);
+ }
+ this.setState({ mockData, targetKeys });
+ },
+ handleChange(targetKeys) {
+ this.setState({ targetKeys });
+ },
+ render() {
+ return (
+ <Transfer
+ dataSource={this.state.mockData}
+ showSearch
+ targetKeys={this.state.targetKeys}
+ onChange={this.handleChange}
+ render={item => item.title} />
+ );
+ }
+});
+
+ReactDOM.render(<App />, mountNode);import { Transfer } from 'antd';
-
-const App = React.createClass({
- getInitialState() {
- return {
- mockData: [],
- targetKeys: [],
- };
- },
- componentDidMount() {
- this.getMock();
- },
- getMock() {
- let targetKeys = [];
- let mockData = [];
- for (let i = 0; i < 20; i++) {
- const data = {
- key: i,
- title: '内容' + (i + 1),
- description: '内容' + (i + 1) + '的描述',
- chosen: Math.random() * 2 > 1
- };
- if (data.chosen) {
- targetKeys.push(data.key);
- }
- mockData.push(data);
- }
- this.setState({ mockData, targetKeys });
- },
- handleChange(targetKeys) {
- this.setState({ targetKeys });
- },
- render() {
- return (
- <Transfer
- dataSource={this.state.mockData}
- showSearch
- targetKeys={this.state.targetKeys}
- onChange={this.handleChange}
- render={item => item.title} />
- );
- }
-});
-
-ReactDOM.render(<App />, mountNode);<BrowserDemo /> 做演示用,无须复制。
import { Menu, Breadcrumb, Icon } from 'antd';
-const SubMenu = Menu.SubMenu;
-
-ReactDOM.render(
- <BrowserDemo>
- <div className="ant-layout-aside">
- <aside className="ant-layout-sider">
- <div className="ant-layout-logo"></div>
- <Menu mode="inline" theme="dark"
- defaultSelectedKeys={['1']} defaultOpenKeys={['sub1']}>
- <SubMenu key="sub1" title={<span><Icon type="user" />导航一</span>}>
- <Menu.Item key="1">选项1</Menu.Item>
- <Menu.Item key="2">选项2</Menu.Item>
- <Menu.Item key="3">选项3</Menu.Item>
- <Menu.Item key="4">选项4</Menu.Item>
- </SubMenu>
- <SubMenu key="sub2" title={<span><Icon type="laptop" />导航二</span>}>
- <Menu.Item key="5">选项5</Menu.Item>
- <Menu.Item key="6">选项6</Menu.Item>
- <Menu.Item key="7">选项7</Menu.Item>
- <Menu.Item key="8">选项8</Menu.Item>
- </SubMenu>
- <SubMenu key="sub3" title={<span><Icon type="notification" />导航三</span>}>
- <Menu.Item key="9">选项9</Menu.Item>
- <Menu.Item key="10">选项10</Menu.Item>
- <Menu.Item key="11">选项11</Menu.Item>
- <Menu.Item key="12">选项12</Menu.Item>
- </SubMenu>
- </Menu>
- </aside>
- <div className="ant-layout-main">
- <div className="ant-layout-header"></div>
- <div className="ant-layout-breadcrumb">
- <Breadcrumb>
- <Breadcrumb.Item>首页</Breadcrumb.Item>
- <Breadcrumb.Item>应用列表</Breadcrumb.Item>
- <Breadcrumb.Item>某应用</Breadcrumb.Item>
- </Breadcrumb>
- </div>
- <div className="ant-layout-container">
- <div className="ant-layout-content">
- <div style={{ height: 590 }}>
- 内容区域
- </div>
- </div>
- </div>
- <div className="ant-layout-footer">
- Ant Design 版权所有 © 2015 由蚂蚁金服体验技术部支持
- </div>
- </div>
- </div>
- </BrowserDemo>
-, document.getElementById('spec-layout-demo-aside'));.ant-layout-aside {
- position: relative;
- min-height: 100%;
-}
-
-.ant-layout-aside .ant-layout-logo {
- width: 150px;
- height: 32px;
- background: #333;
- border-radius: 6px;
- margin: 16px 24px 16px 28px;
-}
-
-.ant-layout-aside .ant-layout-sider {
- width: 224px;
- background: #404040;
- position: absolute;
- overflow: auto;
- padding-bottom: 24px;
- height: 100%;
-}
-
-.ant-layout-aside .ant-layout-sider > .ant-menu {
- margin-bottom: 20px;
-}
-
-.ant-layout-aside .ant-layout-header {
- background: #fff;
- height: 64px;
- border-bottom: 1px solid #e9e9e9;
-}
-
-.ant-layout-aside .ant-layout-breadcrumb {
- margin: 7px 0 -17px 24px;
-}
-
-.ant-layout-aside .ant-layout-main {
- margin-left: 224px;
-}
-
-.ant-layout-aside .ant-layout-container {
- margin: 24px 16px;
-}
-
-.ant-layout-aside .ant-layout-content {
- background: #fff;
- padding: 24px;
-}
-
-.ant-layout-aside .ant-layout-footer {
- height; 64px;
- line-height: 64px;
- text-align: center;
- font-size: 12px;
- color: #999;
- background: #fff;
- border-top: 1px solid #e9e9e9;
- width: 100%;
-}顶级导航在头部,次级导航在侧边栏。
import { Menu, Breadcrumb, Icon } from 'antd';
+const SubMenu = Menu.SubMenu;
+
+ReactDOM.render(
+ <BrowserDemo>
+ <div className="ant-layout-aside">
+ <aside className="ant-layout-sider">
+ <div className="ant-layout-logo"></div>
+ <Menu mode="inline" theme="dark"
+ defaultSelectedKeys={['1']} defaultOpenKeys={['sub1']}>
+ <SubMenu key="sub1" title={<span><Icon type="user" />导航一</span>}>
+ <Menu.Item key="1">选项1</Menu.Item>
+ <Menu.Item key="2">选项2</Menu.Item>
+ <Menu.Item key="3">选项3</Menu.Item>
+ <Menu.Item key="4">选项4</Menu.Item>
+ </SubMenu>
+ <SubMenu key="sub2" title={<span><Icon type="laptop" />导航二</span>}>
+ <Menu.Item key="5">选项5</Menu.Item>
+ <Menu.Item key="6">选项6</Menu.Item>
+ <Menu.Item key="7">选项7</Menu.Item>
+ <Menu.Item key="8">选项8</Menu.Item>
+ </SubMenu>
+ <SubMenu key="sub3" title={<span><Icon type="notification" />导航三</span>}>
+ <Menu.Item key="9">选项9</Menu.Item>
+ <Menu.Item key="10">选项10</Menu.Item>
+ <Menu.Item key="11">选项11</Menu.Item>
+ <Menu.Item key="12">选项12</Menu.Item>
+ </SubMenu>
+ </Menu>
+ </aside>
+ <div className="ant-layout-main">
+ <div className="ant-layout-header"></div>
+ <div className="ant-layout-breadcrumb">
+ <Breadcrumb>
+ <Breadcrumb.Item>首页</Breadcrumb.Item>
+ <Breadcrumb.Item>应用列表</Breadcrumb.Item>
+ <Breadcrumb.Item>某应用</Breadcrumb.Item>
+ </Breadcrumb>
+ </div>
+ <div className="ant-layout-container">
+ <div className="ant-layout-content">
+ <div style={{ height: 590 }}>
+ 内容区域
+ </div>
+ </div>
+ </div>
+ <div className="ant-layout-footer">
+ Ant Design 版权所有 © 2015 由蚂蚁金服体验技术部支持
+ </div>
+ </div>
+ </div>
+ </BrowserDemo>
+, document.getElementById('spec-layout-demo-aside'));.ant-layout-aside {
+ position: relative;
+ min-height: 100%;
+}
+
+.ant-layout-aside .ant-layout-logo {
+ width: 150px;
+ height: 32px;
+ background: #333;
+ border-radius: 6px;
+ margin: 16px 24px 16px 28px;
+}
+
+.ant-layout-aside .ant-layout-sider {
+ width: 224px;
+ background: #404040;
+ position: absolute;
+ overflow: auto;
+ padding-bottom: 24px;
+ height: 100%;
+}
+
+.ant-layout-aside .ant-layout-sider > .ant-menu {
+ margin-bottom: 20px;
+}
+
+.ant-layout-aside .ant-layout-header {
+ background: #fff;
+ height: 64px;
+ border-bottom: 1px solid #e9e9e9;
+}
+
+.ant-layout-aside .ant-layout-breadcrumb {
+ margin: 7px 0 -17px 24px;
+}
+
+.ant-layout-aside .ant-layout-main {
+ margin-left: 224px;
+}
+
+.ant-layout-aside .ant-layout-container {
+ margin: 24px 16px;
+}
+
+.ant-layout-aside .ant-layout-content {
+ background: #fff;
+ padding: 24px;
+}
+
+.ant-layout-aside .ant-layout-footer {
+ height; 64px;
+ line-height: 64px;
+ text-align: center;
+ font-size: 12px;
+ color: #999;
+ background: #fff;
+ border-top: 1px solid #e9e9e9;
+ width: 100%;
+}