ant-design/components/select/demo/multiple.md
黑雨 91821d4d3a
feat: select edit demo to data driven (#37601)
* feat: select edit demo to data driven

* feat: edit demo to data driven

Co-authored-by: 二货机器人 <smith3816@gmail.com>
2022-09-19 18:01:16 +08:00

1.0 KiB

order title
2
zh-CN en-US
多选 multiple selection

zh-CN

多选,从已有条目中选择。

en-US

Multiple selection, selecting from existing items.

import { Select } from 'antd';
import React from 'react';
import type { SelectProps } from 'antd';

const options: SelectProps['options'] = [];
for (let i = 10; i < 36; i++) {
  options.push({
    label: i.toString(36) + i,
    value: i.toString(36) + i,
  });
}

const handleChange = (value: string[]) => {
  console.log(`selected ${value}`);
};

const App: React.FC = () => (
  <>
    <Select
      mode="multiple"
      allowClear
      style={{ width: '100%' }}
      placeholder="Please select"
      defaultValue={['a10', 'c12']}
      onChange={handleChange}
      options={options}
    />
    <br />
    <Select
      mode="multiple"
      disabled
      style={{ width: '100%' }}
      placeholder="Please select"
      defaultValue={['a10', 'c12']}
      onChange={handleChange}
      options={options}
    />
  </>
);

export default App;