Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

debounchow use input debounce in javascript vue.js

<template>
  <div>
    <input type="text" @input="debounceSearch" placeholder="Search">
    <span v-if="typing">You are typing</span>
    <span v-if="message">You typed: {{message}}</span>
  </div>
</template>
<script>
export default {
  data: () => ({
    message: null,
    typing: null,
    debounce: null
  }),

  methods: {
    debounceSearch(event) {
      this.message = null
      this.typing = 'You are typing'
      clearTimeout(this.debounce)
      this.debounce = setTimeout(() => {
        this.typing = null
        this.message = event.target.value
      }, 600)
    }
  }
}
</script>
Source by codesandbox.io #
 
PREVIOUS NEXT
Tagged: #debounchow #input #debounce #javascript
ADD COMMENT
Topic
Name
6+5 =