react+antd+select+lodash模糊搜索防抖


import { debounce } from 'lodash';

  

<Form.Item label="前置任務" vvspan={24} labelCol={{ md: 3 }} wrapperCol={{ md: 21 }}>
                            {getFieldDecorator('frontTaskId', {
                                initialValue: getPath(initInfo, 'frontTaskId', undefined)
                            })(
                                <Select
                                    placeholder="請選擇前置任務"
                                    allowClear
                                    showSearch
                                    onSearch={handleSearchFront}
                                    onChange={handleChangeFront}
                                    filterOption={false}
                                >
                                    {frontList.map(item => (
                                        <Option key={item.taskId} value={item.taskId}>
                                            {item.taskName}
                                        </Option>
                                    ))}
                                </Select>
                            )}
                        </Form.Item>

  

    // 前置任務列表搜索
    const handleSearchFront = debounce(value => {
        fetchFrontList(value);
    }, 200);
    // const handleSearchFront = value => {
    //     fetchFrontList(value);
    // };
    const handleChangeFront = debounce(value => {
        if (value === undefined) {
            fetchFrontList();
        }
    }, 200);
    // const handleChangeFront = value => {
    //     if (value === undefined) {
    //         fetchFrontList();
    //     }
    // };

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM