wl-core
无框架依赖的核心层及工具层封装
下列说明中 export 内的方法名,均可 import { xx } from 'wl-core' 导入使用
array
提供有关数组的操作方法 Function
export {
valInDeep,
flattenDeep,
flattenDeepParents,
regDeepParents,
arrayToTree,
patchTreeChain,
locationAfterDelete,
splicParentsUntil,
intersectionBy,
deepClone,
getMax,
getMin,
autoPositionAfterDelete,
};
event
提供对浏览器事件的封装 Function
export {
throttle,
debounce
}
Storage
提供对Storage操作的类,包括local和session两种 Class
export {
Storage
}
均为静态方法,可直接调用。它包括有:
Storage.set('key','value','type[local|session]')
Storage.get('key','type[local|session]')
Storage.remove('key','type[local|session]')
Storage.had('key','type[local|session]')
Storage.clear('type[local|session]')
Storage.count('type[local|session]')
Time
提供对时间操作的类 Class
export {
Time
}
主要用于对时间进行两次及以上操作的情况!对于时间格式化,在wl-vue中提供了time过滤器
- 使用需要先实例化,全部方法如下:
const timer = new Time('2020-02-14', 'YYYY/MM/DD');
timer.dayjs(date)
timer.format(format)
timer.add(num, unit)
timer.subtract(num, unit)
timer.isBefore(date, unit)
timer.diff(date, unit)
- 静态方法可直接调用
Time.quickFormat(new Date(), 'YYYY/MM/DD')
Time.init(new Date())
Type
提供判断数据类型的类 Class
export {
DataType
}
均为静态方法,可直接调用。它包括有:
DataType.isObject(data)
DataType.isEmptyObject(data)
DataType.isArray(data)
DataType.isEmptyArray(data)
validate
数据验证
export {
vaPhone,
regPhone,
isNum,
isInteger,
validate,
}
WlNumber
提供精确数字计算的类 Class
export {
WlNumber
}
const beginNum = new WlNumber(1);
beginNum.plus(2)
beginNum.minus(2)
beginNum.times(2)
beginNum.div(2)
beginNum.mod(2)
beginNum.abs()
beginNum.gt(2)
beginNum.gte(2)
beginNum.lt(2)
beginNum.lte(2)
静态方法
WlNumber.toNumber(val)
常用JWT校验及解析方法
import { VaJwt } from "wl-core"
const payload = VaJwt.payloadAtob(jwt);
版本更新说明
v1.1.9 修复数组方法arrayToTree的一个默认参数错误