@antdp/fuzzy-query
v2.1.1
Published
基于antd封装的组件 模糊查询 自定义提示
Downloads
38
Readme
FuzzyQuery 模糊查询
依赖安装
npm i @antdp/fuzzy-query
基本使用
import React from 'react';
import { Input, Col, InputNumber, Button, Select ,Form} from 'antd';
import FuzzyQuery from '@antdp/fuzzy-query';
import 'antd/dist/reset.css';
const Query =() => {
const [value, setValue] = React.useState([])
// 根据key模糊查询组织
const selectLike = async () => {
return Array.from({ length: 20 }).map((_, index) => {
return {
label: `名称---${index}`,
phone: index,
}
})
};
return (
<div>
<FuzzyQuery
request={selectLike}
mode='multiple'
value={value}
onChange={setValue}
placeholder="请选择"
columns={[{ dataIndex: "label", title: "用户名" }, { dataIndex: "phone", title: "电话" }]}
fieldNames={{ value: "phone" }}
/>
</div>
);
};
export default Query
延迟时间5s
import React from 'react';
import { Input, Col, InputNumber, Button, Select ,Form} from 'antd';
import FuzzyQuery from '@antdp/fuzzy-query';
import 'antd/dist/reset.css';
const Query =() => {
const [value, setValue] = React.useState([])
// 根据key模糊查询组织
const selectLike = async () => {
return Array.from({ length: 20 }).map((_, index) => {
return {
label: `名称---${index}`,
phone: index,
}
})
};
return (
<div>
<FuzzyQuery
request={selectLike}
mode='multiple'
value={value}
onChange={setValue}
placeholder="请选择"
columns={[{ dataIndex: "label", title: "用户名" }, { dataIndex: "phone", title: "电话" }]}
fieldNames={{ value: "phone" }}
debounceTimeout={5000}
/>
</div>
);
};
export default Query
API
| 参数 | 说明 | 类型 | 默认值 |
| -------- | -------- | -------- | -------- |
| columns | 表格标题 | TablesProps["columns"]
| - |
| request | 请求 | (params: any) => Promise<{ label: any, value: any, [s: string]: any }[]>
| - |
| debounceTimeout | 延迟时间 | number
| - |