在需要使用的组件引用
import { _debounce } from "@/utils/public";
在 methods 中使用
methods: { // 改变场数 changefield: _debounce(function(_type, index, item) { // do something ... }, 200) }
[](()应用:
==================================================================
[](()函数防抖(debounce)
在事件被触发n秒后再执行回调,如果在这n秒内又被触发,则重新计时。
<body> <input type="text" id='unDebounce'> </body> </html> <script> //模拟一段ajax请求 function ajax(content){ console.log('ajax request ' + content) }; letinputa = document.getEleme