32 字
1 分钟
rn通过lodash实现事件防抖
_.debounce()
_.debounce(func, [wait=0], [options={}])参数
func: (Function)要防抖动的函数。[wait=0]: (number)需要延迟的毫秒数。[options={}]: (Object)选项对象。[options.leading=false]: (boolean)指定在延迟开始前调用。[options.maxWait]: (number)设置 func 允许被延迟的最大值。[options.trailing=true]: (boolean)指定在延迟结束后调用。返回值
return: (Function)返回新的 debounced(防抖动)函数。应用
TextInput 实现停止输入文字 600ms 后自动调用自定方法 onRefresh 获取数据
<TextInput onChange={this.changeSearchText} /> changeSearchText = lodash.debounce( () => { this.onRefresh(); // 异步获取数据列表方法 }, 600, {trailing: true},); 分享
如果这篇文章对你有帮助,欢迎分享给更多人!
rn通过lodash实现事件防抖
https://marrydream.top/posts/web前端/rn通过lodash实现事件防抖/ 部分信息可能已经过时
相关文章 智能推荐