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

# useThrottleFn

用来处理节流函数的 Hook。

## 使用

```
<template>
    <div>
      <p style="marginTop: 16"> Clicked count: {{throttleFnValue}} </p>
      <button type="button" @click="run">
        useThrottleFn测试
      </button>
    </div>
</template>

<script lang="ts">

import { ref } from 'vue';
import { useThrottleFn } from 'v3hooks';


export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },

  setup() {
    const throttleFnValue = ref(1);
    const { run } = useThrottleFn(()=>{
      throttleFnValue.value++
    },500)

    return {
      throttleFnValue,
      run,
    }
  }
}
</script>
```

频繁调用 run，但只会每隔 500ms 执行一次相关函数。

## Api

### Params

|  参数  |     说明     |     类型     |  默认值 |
| :--: | :--------: | :--------: | :--: |
|  fn  |  需要节流执行的函数 | () => void |   -  |
| wait | 超时时间，单位为毫秒 |   number   | 1000 |
