Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize vue Anti-shaking

Shulou Source: shulou.com Published: 2022-06-02 00:03:10 12月03日 Update

This article mainly introduces the relevant knowledge of "how to achieve vue anti-shaking". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to achieve vue anti-shaking" can help you solve the problem.

1. First, create a new debounce.js code as follows: const debounce=function (fn, delay) {

Let timer = null

Return function () {

Let content = this

Let args = arguments

If (timer) {

ClearTimeout (timer)

}

Timer = setTimeout () = > {

Fn.apply (content,args)

}, delay)

}

}

Export default debounce2. Introduce debounce into the vue file that needs anti-shake, as follows; this is the anti-shake of the 500ms of an input box

Import debounce from ".. / utils/debounce"

Export default {

Name: "alarm"

Data () {

Return {

Input:''

}

}

Methods: {

ChangeSeletc:debounce (function () {

Console.log (this.input)

}, 500)

}

}

This is the end of the content about "how to achieve vue anti-shaking". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Knowledge content industry different practical code practical practical documents articles methods more cases knowledge points articles information channels process this is the problem Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology macOS Redmi OPPO Reno