Skip to content

防抖

安装

typescript
import { useDebouncePlugin } from '@pluve/use-request-vue';

使用方式

typescript
import useRequest from '@pluve/use-request-vue';

const { data, run } = useRequest((keyword) => fetch(`/api/search?q=${keyword}`).then((res) => res.json()), {
  manual: true,
  debounceInterval: 300, // 防抖等待时间(毫秒)
});

// 快速输入时,只有停止输00ms后才会发送请run('vue');
run('vue3');
run('vue3 composition');
// 只有最后一次调用会真正发送请```