# useDebounce

#### 基础用法

```html
<template>
  <div>
    <label>Value:</label>
    <input
      type="text"
      :value="value"
      placeholder="请输入"
      @input="
        (e) => {
          changeValue(e);
        }
      "
    />
    <div>debouncedValue{{ debouncedValue }}</div>
  </div>
</template>

<script lang="ts" setup>
import { ref, watch, Ref } from "vue";
import { useDebounce } from "hooks-vue3";
const value = ref("1");
const debouncedValue = useDebounce<Ref<string>>(value, {
  wait: 500,
});
const changeValue = (e: any) => {
  value.value = e.target.value;
};

watch(debouncedValue, () => {
  console.log("debouncedValue", debouncedValue);
});
</script>
```

### API

```typescript
import type { DebounceSettings } from 'lodash-es/debounce';
interface Options extends DebounceSettings {
  wait?: number;
}
const debounceValue = useDebounce(value:T,{ wait: Options });
```

### 参数

* value (T): 要防抖动的值。
* \[wait=1000] (number): 需要延迟的毫秒数。
* \[options=] (Object): 选项对象。
* \[options.leading=false] (boolean): 指定在延迟开始前调用。
* \[options.maxWait] (number): 设置 func 允许被延迟的最大值。
* \[options.trailing=true] (boolean): 指定在延迟结束后调用。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://laterly.gitbook.io/hooks-vue3/usedebounce.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
