
utils
IT~少年人
渴望光荣
展开
-
前端开发 节流和防抖
1、防抖常见案例:用户搜索框连续输入时,当用户停止输入后获取查询结果。 // 防抖 function debounce(fn, delay=500) { let timer = null; return function(){ if (timer){ clearTimeout(timer) } timer = setTimeout(() => { fn.apply(this, arguments); timer = null;原创 2020-08-07 16:43:50 · 286 阅读 · 0 评论 -
前端js Aes对本地存储数据进行加密解密
1、npm install crypto-js2、编写LocalStorage类const CryptoJS = require('crypto-js');class LocalStorage { constructor() { this.autoEncrypt = true this.aseKey = '12345678' } setItem(key, value) { var v = value if (th原创 2020-07-07 17:21:22 · 3469 阅读 · 1 评论 -
ES6语法编写常用工具utils类
1、创建Config类,用户存储一些全局变量class Config { constructor() { this.BASE_URL = 'http://www.baidu.com' this.IMAGE_URL = 'http://www.cdn.baidu.com' this.SITE_PREFIX = 'ZP_' this.AJAX_CONFIG = { timeout: 10000,原创 2020-06-28 10:44:46 · 2316 阅读 · 0 评论