【问题标题】:I need react multi-select with virtualized list options我需要对虚拟化列表选项进行多选反应
【发布时间】:2022-12-12 16:17:45
【问题描述】:

我有一个多选组件,其中包含大量需要很长时间才能加载的选项数据。

我用 react-select-virtualized 和 它工作正常,但它还不支持多选。

取自:(https://github.com/guiyep/react-select-virtualized#what-we-do-support-and-dont-from-react-select)

我想要一个具有多个值选择选项的虚拟化选择框。

【问题讨论】:

    标签: react-select react-virtualized


    【解决方案1】:

    检查下面的stackblitz 应用程序。对我的要求很有帮助。

    https://stackblitz.com/edit/react-select-v2-virtualized

    在这个应用程序中,他们用react-virtualized创建了一个react-select组件。

    示例代码:

    const MenuList = props => {
      const rows = props.children;
      const rowRenderer = ({ key, index, isScrolling, isVisible, style }) => (
        <div key={key} style={style}>{rows[index]}</div>
      );
    
      return (
        <List
          style={{ width: '100%' }}
          width={300}
          height={300}
          rowHeight={30}
          rowCount={rows.length}
          rowRenderer={rowRenderer}
        />
      )
    }
    

    内部渲染函数

    <Select
       components={{ MenuList }}
       defaultValue={this.state.options[10]}
       options={this.state.options}
     />
    

    【讨论】:

      猜你喜欢
      • 2017-08-28
      • 2021-02-03
      • 1970-01-01
      • 2018-10-12
      • 2017-07-13
      • 2020-08-12
      • 2011-11-26
      • 2018-11-26
      • 2019-08-01
      相关资源
      最近更新 更多