#1831·dash

[功能请求] 添加 dcc.Dropdown 选项分组

作者: BvdLind创建于 2021年11月14日更新于 2026年9月11日
标签featureP3

import React from "react"; import "../styles/sideBar.css"; import Select from 'react-select'

export default class SelectWrapper extends React.Component { constructor(props) { super(props); this.state = { value: this.props.options[0] }; this.handleChange = this.handleChange.bind(this); }

handleChange = selectedOption => { this.props.setProps({ value: selectedOption.value }); this.setState({ value: selectedOption }); };

render() { return <Select {...this.props} onChange={this.handleChange} value={this.props.value} /> } }

SelectWrapper.defaultProps = { clearable: true, disabled: false, multi: false, searchable: true, optionHeight: 35, persisted_props: ['value'], persistence_type: 'local', };

SelectWrapper.propTypes = { /**

  • Select options */ options: PropTypes.array,

/**

  • The value of the input. If multi is false (the default)
  • then value is just a string that corresponds to the values
  • provided in the options property. If multi is true, then
  • multiple values can be selected at once, and value is an
  • array of items with values corresponding to those in the
  • options prop. */ value: PropTypes.oneOfType([ PropTypes.string, PropTypes.number, PropTypes.bool, PropTypes.arrayOf( PropTypes.oneOfType([ PropTypes.string,