utils
Yomuki
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【class】接口使用类封装
/* * @Desc: 接口使用类 * @Author: Yomuki * @Date: 2021-08-25 11:14:00 * @LastEditors: 曾茹菁 * @LastEditTime: 2021-08-25 11:43:24 */ // 接口类生成对象 const apiClassObj = { post: function () {}, get: function () {}, }; // 用户信息(vuex) const user = {}; export .原创 2021-08-25 11:44:13 · 410 阅读 · 0 评论 -
2021-07-21 replaceAll
(function() { function replaceAll(substr, newSubstr) { var regExp = new RegExp(substr, "g"); return this.replace(regExp, newSubstr); } if (!String.prototype.hasOwnProperty("replaceAll")) { String.prototype.replaceAll = replaceAll; } }).原创 2021-07-21 16:08:28 · 163 阅读 · 0 评论 -
【utils】日期/时间
/** * @description: 获取日期 yy-mm-dd * @param {*} date * @param {*} separate * @return {*} */ export function getDateStr(date = new Date(), separate = "-") { if (!(date instanceof Date)) return; let yy = date.getFullYear(); let mm = padStartDay(da.原创 2021-03-25 09:43:10 · 241 阅读 · 0 评论 -
【utils】提取url中的参数/手机号验证/身份证验证/护照验证
/** * @description: 获取url中的参数 * @param {*} * @return {*} */ export function getUrlParams(name) { const reg = new RegExp("[?|&]" + name + "=([^&]*)(&|$)", "i"); const res = window.location.href.match(reg); // console.log(res); if (r.原创 2021-03-25 09:36:34 · 344 阅读 · 0 评论 -
【utils】防抖和节流
节流 function throttle(callback, wait = 300) { let start = 0; return function (e) { let now = Date.now(); if (now - start >= wait) { callback.call(this, e); start = now; } }; } 防抖 function debounce(callback, time = 300)原创 2021-02-21 16:17:16 · 415 阅读 · 0 评论 -
【utils】Proxy应用:通过obj.attr直接获取深层属性值
/** * @description: 获取对象属性值(同名取第一个的值) * @param {*} obj * @param {string} attrName * @return {*} any */ export function getObjectAttrValue(obj, attrName: string | number | symbol): any { if (!(typeof obj === 'object')) return undefined if (obj.原创 2021-02-13 10:11:26 · 402 阅读 · 0 评论
分享