zoukankan      html  css  js  c++  java
  • 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)
    }
    
    
  • 相关阅读:
    make dep
    TS流的解析
    qt ISO C++ forbids declaration of 'XXXX' with no type
    qt 中文乱码
    qt creator 快捷键 (一)
    qt 坐标变换
    Qt常用类及类方法简介之 QAction类
    QWidget背景(透明)问题
    如何在 QWidget 窗口上弹出右键菜单
    qt 事件
  • 原文地址:https://www.cnblogs.com/founderswitch/p/7976629.html
Copyright © 2011-2022 走看看