UNPKG

zgg-ui

Version:

2.0.1 正式版本 基于 Vue 3、UniApp 和 TypeScript 开发的多端适配移动端 UI 组件库,旨在提供丰富的组件集合,帮助开发者快速构建多端响应式的移动应用界面

29 lines (24 loc) 702 B
import { isObject } from '@vue/shared' import { debounce } from './debounce' import type { DebouncedFunc, ThrottleSettings } from './_common' const FUNC_ERROR_TEXT = 'Expected a function' export function throttle<T extends (...args: any) => any>( func: T, wait?: number, options?: ThrottleSettings ): DebouncedFunc<T> { let leading = true, trailing = true if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT) } if (isObject(options)) { leading = 'leading' in options ? !!options.leading : leading trailing = 'trailing' in options ? !!options.trailing : trailing } return debounce(func, wait, { leading, maxWait: wait, trailing, }) }