> For the complete documentation index, see [llms.txt](https://laterly.gitbook.io/hooks-vue3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://laterly.gitbook.io/hooks-vue3/usethrottle.md).

# useThrottle

#### 基础用法

```html
<template>
  <p>Count: {{ count }}</p>

  <button @click="handleClick">Increment</button>
  <p>throttledSetCount:{{ throttledSetCount }}</p>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { useThrottle } from 'hooks-vue3';
const count = ref<number>(0);
const handleClick = () => {
  count.value = count.value + 1;
};
const throttledSetCount = useThrottle<number>(count, {
  wait: 1000,
});
</script>
l
```

### API

```typescript
import type { ThrottleSettings } from 'lodash-es/throttle';
interface UseThrottleOptions extends ThrottleSettings {
  wait?: number;
}
const throttleValue = useThrottle(value:T,{ wait: Options });
```

### 参数

* value (T): 要节流的值。
* \[wait=0] (number): 需要节流的毫秒。
* \[options=] (Object): 选项对象
* \[options.leading=false] (boolean): 指定调用在节流开始前。
* \[options.trailing=true] (boolean): 指定调用在节流结束后。
