vue-使用lodash库进行函数限流
哔哩哔哩
2023-04-22 10:59:08
(资料图)
<template id="Application"> <div>按钮点击{{count}}次</div> <button @click="click">按钮</button></template><script>import _ from 'lodash';export default { name: "throttle", data(){ return{ throttle: false, count:0, } }, methods:{ // 因为input输入时需要请求后台,结果每次输入一个字符都会请求,连续输就连续请求 debounce防抖 延时500ms click:_.debounce(function () { this.count = this.count + 1 }, 500) }}</script><style scoped></style>
x