当前位置:网站首页>[pit avoidance means "difficult"] antd select fuzzy search

[pit avoidance means "difficult"] antd select fuzzy search

2022-06-25 13:16:00 Coconut brine Engineer

 		<Select
              allowClear
              showSearch
              filterOption={
    (input, option) => {
    
                if (option && option.title) {
    
                  return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                } else {
    
                  return true
                }
              }}
              defaultActiveFirstOption={
    false}
              onChange={
    handleSourceChange}
              placeholder=" Please select "
              style={
    {
     width: 280 }}
            >
              {
    list?.map((v: any) => {
    
                return (
                  <Select.Option value={
    v.id} key={
    v.id} title={
    v.name}>
                    {
    v.name}
                  </Select.Option>
                );
              })}
		</Select>

️ Be careful :Select.Option Be sure to configure title, Otherwise, fuzzy matching is impossible .

<Select.Option value={
    v.id} key={
    v.id} title={
    v.name}>
       {
    v.name}
</Select.Option>
原网站

版权声明
本文为[Coconut brine Engineer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200526312996.html