Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 2.73 KB

File metadata and controls

34 lines (23 loc) · 2.73 KB

v-debounce-click medium #Directives

By webfansplz @webfansplz

Take the Challenge    简体中文

For this challenge, we're going to implement a debounced-click-directive. Lets go 👇:

<script setup lang='ts'>

/**
  * Implement the custom directive
 * Make sure the `onClick` method only gets triggered once when clicked many times quickly
 * And you also need to support the debounce delay time option. e.g `v-debounce-click:ms`
 *
*/

const VDebounceClick = {

}

function onClick() {
  console.log("Only triggered once when clicked many times quickly")
}

</script>

<template>
  <button v-debounce-click:200="onClick">
    Click on it many times quickly
  </button>
</template>

Back Share your Solutions Check out Solutions