useDebounce

用来处理防抖值的 Hook。

基础用法

DebouncedValue: 1

<template>
  <div>
    <el-input v-model="debounceCurrValue" placeholder="Typed value" style="width: 280" />
    <p style="marginTop: 16">DebouncedValue: {{ debounceValue }}</p>
  </div>
</template>

<script lang="ts">

import { ref } from 'vue';
import { useDebounce } from 'dz-hooks';

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

  setup() {
    const debounceCurrValue = ref(1);
    const debounceValue = useDebounce(debounceCurrValue, 500);

    return {
      debounceCurrValue,
      debounceValue,
    }
  }
}
</script>

Api

参数说明类型默认值
value需要防抖的值any-
wait超时时间,单位为毫秒number1000
Last Updated:
Contributors: huzhiwei