input 输入速度和方向判断搜索功能的延迟请求
Posted Mr.方
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了input 输入速度和方向判断搜索功能的延迟请求相关的知识,希望对你有一定的参考价值。
1、input 输入速度和方向判断
var wxApp = {} wxApp.click = function (str,speed) { var lastInput = { d: "", flag: true, lastTime: 0, twoClickTime:300, init:function (str,speed) { return { isAdd: this.isAdd(str,speed), speedValid:this.two_click(speed) } }, isAdd: function (str) { var now_time = new Date(); if (str - this.d > 0) { this.flag = true } else { this.flag = false } this.d = str }, two_click:function(time){ var nowTime = (new Date()).getTime(); var time = time || this.twoClickTime; var f = (nowTime - this.lastTime) > time ? true : false; this.lastTime = nowTime; return f; } } return lastInput.init(str,speed) }
2、搜索
wxApp.setTimeoutSearch = {}; wxApp.search = function (that,options) { var type = options.type, speed = options.speed || 300; clearTimeout(this.setTimeoutSearch); this.setTimeoutSearch = setTimeout(() => { this.getStorage("UserId",(res) => { var data = { ApplyUserId:res } this.extend(data,options.data) this.request({ url:type, data:data, success:(rs) =>{ that.setData({ // options.success }) } }) }) },speed) }
以上是关于input 输入速度和方向判断搜索功能的延迟请求的主要内容,如果未能解决你的问题,请参考以下文章