chore(防抖节流工具): 新增注释
This commit is contained in:
parent
a565442c60
commit
7a0aa39d5d
@ -1,6 +1,6 @@
|
||||
import { getCurrentInstance, onUnmounted } from 'vue'
|
||||
|
||||
// 防抖
|
||||
// 防抖(仅在最新一次请求的计时结束后执行)
|
||||
export function useDebounce(fn, delay = 500, immediate = false) {
|
||||
let timer = null
|
||||
let instance = getCurrentInstance() // 获取当前组件实例
|
||||
@ -42,7 +42,7 @@ export function useDebounce(fn, delay = 500, immediate = false) {
|
||||
return debounced
|
||||
}
|
||||
|
||||
// 节流
|
||||
// 节流(执行第一次请求,直到计时器结束,才可以重新请求)
|
||||
export function useThrottle(fn, delay = 1000) {
|
||||
let lastCall = 0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user