小编dev*_*Dev的帖子

如何自定义反应选择设置搜索过滤器

const ItemOptions: SelectValueInterface[] = Item.map((e) => ({
  value: e.ItemId,
  label: `${e.ItemName} (Item ID : ${e.ItemId})`,
}));
const options = [
  {
    label: 'ITEM NAME (Item ID)',
    options: ItemOptions,
  },
];

const formatGroupLabel = (data: any) => (
  <div className={styles.formatGroupLabel}>
    <span>{data.label}</span>
  </div>
);

<Select
  placeholder="Select Name"
  options={options}
  formatGroupLabel={formatGroupLabel}
  classNamePrefix="select-list"
  value={ItemOptions.filter((option) => option.value === selectedItemId)}
  onChange={filterByItemID}
/>;
Run Code Online (Sandbox Code Playgroud)

当我输入搜索/排序时,Item ID它会显示所有选项。我想不检测(Item ID: number)

react-select

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

react-select ×1