1.邮箱
1 | export const isEmail = (s) => { |
2.手机号码
1 | export const isMobile = (s) => { |
3.电话号码
1 | export const isPhone = (s) => { |
4.是否url地址
1 | export const isURL = (s) => { |
5.是否字符串
1 | export const isString = (o) => { |
6.是否数字
1 | export const isNumber = (o) => { |
7.是否boolean
1 | export const isBoolean = (o) => { |
8.是否函数
1 | export const isFunction = (o) => { |
9.是否为null
1 | export const isNull = (o) => { |
10.是否undefined
1 | export const isUndefined = (o) => { |
11.是否对象
1 | export const isObj = (o) => { |
12.是否数组
1 | export const isArray = (o) => { |
13.是否时间
1 | export const isDate = (o) => { |
14.是否正则
1 | export const isRegExp = (o) => { |
15.是否错误对象
1 | export const isError = (o) => { |
16.是否Symbol函数
1 | export const isSymbol = (o) => { |
17.是否Promise对象
1 | export const isPromise = (o) => { |
18.是否Set对象
1 | export const isSet = (o) => { |
19.是否是微信浏览器
1 | export const isWeiXin = () => { |
20.是否是移动端
1 | export const isDeviceMobile = () => { |
21.是否是QQ浏览器
1 | export const isQQBrowser = () => { |
22.是否是爬虫
1 | export const isSpider = () => { |
23.是否ios
1 | export const whichDevice = (device) => { |
24.是否为PC端
1 | export const isPC = () => { |
25.去除html标签
1 | export const removeHtmltag = (str) => { |
26.获取url参数
1 | export const getQueryString = (name) => { |
27.动态引入js
1 | export const injectScript = (src) => { |
28.根据url地址下载
1 | export const download = (url) => { |
29.el是否包含某个class
1 | export const hasClass = (el, className) => { |
30.el添加某个class
1 | export const addClass = (el, className) => { |
31.el去除某个class
1 | export const removeClass = (el, className) => { |
32.获取滚动的坐标
1 | export const getScrollPosition = (el = window) => ({ |
33.滚动到顶部
1 | export const scrollToTop = () => { |
34.el是否在视口范围内
1 | export const elementIsVisibleInViewport = (el, partiallyVisible = false) => { |
35.洗牌算法随机
1 | export const shuffle = (arr) => { |
36.劫持粘贴板
1 | export const copyTextToClipboard = (value) => { |
37.判断类型集合
1 | export const checkStr = (str, type) => { |
38.严格的身份证校验
1 | export const isCardID = (sId) => { |
39.随机数范围
1 | export const random = (min, max) => { |
40.将阿拉伯数字翻译成中文的大写数字
1 | export const numberToChinese = (num) => { |
41.将数字转换为大写金额
1 | export const changeToChinese = (Num) => { |
42.判断一个元素是否在数组中
1 | export const contains = (arr, val) => { |
43.数组排序,{type} 1:从小到大 2:从大到小 3:随机
1 | export const sort = (arr, type = 1) => { |
44.去重
1 | export const unique = (arr) => { |
45.求两个集合的并集
1 | export const union = (a, b) => { |
46.求两个集合的交集
1 | export const intersect = (a, b) => { |
47.删除其中一个元素
1 | export const remove = (arr, ele) => { |
48.将类数组转换为数组
1 | export const formArray = (ary) => { |
49.最大值
1 | export const max = (arr) => { |
50.最小值
1 | export const min = (arr) => { |
51.求和
1 | export const sum = (arr) => { |
52.平均值
1 | export const average = (arr) => { |
53.去除空格,type: 1-所有空格 2-前后空格 3-前空格 4-后空格
1 | export const trim = (str, type) => { |
54.字符转换,type: 1:首字母大写 2:首字母小写 3:大小写转换 4:全部大写 5:全部小写
1 | export const changeCase = (str, type) => { |
55.检测密码强度
1 | export const checkPwd = (str) => { |
56.函数节流器
1 | export const debouncer = (fn, time, interval = 200) => { |
57.在字符串中插入新字符串
1 | export const insertStr = (soure, index, newStr) => { |
58.判断两个对象是否键值相同
1 | export const isObjectEqual = (a, b) => { |
59.16进制颜色转RGBRGBA字符串
1 | export const colorToRGB = (val, opa) => { |
60.追加url参数
1 | export const appendQuery = (url, key, value) => { |