Skip to content

useDebounceFn等支持动态的wait #261

@q1557050025

Description

@q1557050025

Description

目前看起来useDebounceFn等 , 不支持 一个动态的wait . 参考以下代码

<template>
  {{ waitTime }}
  <button @click="handleClick">点击</button>
  <button @click="handleSetWaitTime">设置等待时间</button>
</template>


<script lang="ts" setup>
import { ref } from "vue";
import { useDebounceFn } from "vue-hooks-plus";

const waitTime = ref(500);

const { run: fn } = useDebounceFn(
  () => {
    console.log("fn time", new Date().getTime());
  },
  { wait: waitTime.value }
);

const handleClick = () => {
  console.log("click time", new Date().getTime());

  fn();
};

const handleSetWaitTime = () => {
  waitTime.value = 2000;
};
</script>

Suggested solution

希望支持动态wait

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    todoThings to do

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions