ant design 中的 Select 元件常規寫法

weixin_33834679發表於2018-11-27

1.程式碼

import { Select, Spin } from 'antd';
const Option = Select.Option;

<Select
  allowClear
  showSearch
  optionFilterProp="children"
  placeholder="請選擇"
  style={{ width: 200 }}
  onChange={this.handleChange.bind(this)}
  onFocus={this.handleFocus.bind(this)}
  getPopupContainer={triggerNode => triggerNode.parentNode}
  notFoundContent={this.state.dataList.length == 0 ? <Spin size="small" /> : null}
  disabled={false}
>
  {
    (this.state.dataList || []).map((item,index)=>{
      <Option key={index} value={item.code}>{item.name}</Option>
    })
  }
</Select>

.

相關文章