Skip to content
On this page

useDebounce

节流函数,每隔几秒出发一次

基本用法

vue
<template>
  <input style="border: 1px solid #12b981" placeholder="防抖" @input="input" />
  <br /><br />
  {{ desc }}
</template>
<script setup>
import { useThrottle } from "./yik-ui.js";
import { shallowRef } from "vue";
const desc = shallowRef("");
const input = useThrottle((e) => {
  desc.value = e.target.value;
}, 1000);
</script>

参数

参数说明类型默认值
fun回调函数--
wait触发时间,毫秒--