README
Constants
base
通用基础方法
Kind: global constant
base.numberFormat(num, divisor, decimalPlaces, unit)
格式化数值
Kind: static method of base
Param | Type | Description |
---|---|---|
num | Number | String | 数字 |
divisor | Number | 除数(默认值100) |
decimalPlaces | Number | 小数位数(默认值2) |
unit | String | 单位 |
base.easyDeepClone(content)
简易深克隆(无法克隆Function Map Set undefined)
Kind: static method of base
Param | Type | Description |
---|---|---|
content | any | 需要深克隆的内容 |
base.deepClone(content)
深克隆
Kind: static method of base
Param | Type | Description |
---|---|---|
content | any | 需要深克隆的内容 |
check
数据检查
Kind: global constant
check.isNumber(num)
判断是否为数字 (数字字符串也是数字,例如'23'、'123.213')
Kind: static method of check
Param | Type |
---|---|
num | String | Number |
check.isTel(tel)
判断是否为手机号
Kind: static method of check
Param | Type |
---|---|
tel | String | Number |
check.isFalseValue(value)
判断是否有值,但是值为false
Kind: static method of check
Param | Type |
---|---|
value | any |
check.isFunction(param)
判断是否为函数
Kind: static method of check
Param | Type |
---|---|
param | any |
check.isDate(param)
判断是否为时间对象
Kind: static method of check
Param | Type |
---|---|
param | any |
check.isObject(param)
判断是否为Object对象
Kind: static method of check
Param | Type |
---|---|
param | any |
check.isMap(param)
判断是否为Map
Kind: static method of check
Param | Type |
---|---|
param | any |
check.isSet(param)
判断是否为Set
Kind: static method of check
Param | Type |
---|---|
param | any |
check.isString(param)
判断是否为字符串
Kind: static method of check
Param | Type |
---|---|
param | any |
check.isBoolean(param)
判断是否为Boolean
Kind: static method of check
Param | Type |
---|---|
param | any |
date
处理时间
date.dateFormat(date, fmt, autoFillZero)
格式化时间
Kind: static method of date
Param | Type | Description |
---|---|---|
date | Number | String | Date | 需格式化的时间(传入时间戳单位为秒) |
fmt | String | 格式化(默认Y-M-D H:m:s) |
autoFillZero | Boolean | 月日时分秒不足两位时自动补零(默认true) |
file
处理文件
Kind: global constant
file.dataURLToBlob(base64)
base64转为Blob
Kind: static method of file
Param | Type |
---|---|
base64 | String |
file.blobToDataURI(blob)
Blob转为base64
Kind: static method of file
Param | Type |
---|---|
blob | Blob |
file.imgElement2Base64(imgElement)
将img标签转为base64
Kind: static method of file
Param | Type | Description |
---|---|---|
imgElement | HTMLImageElement | img标签 |
file.imgUrl2Base64(imgUrl)
将img网络资源转为base64
Kind: static method of file
Param | Type | Description |
---|---|---|
imgUrl | String | img地址 |
file.getNetFile(url, responseType, options)
获取网络资源文件
Kind: static method of file
Param | Type | Description |
---|---|---|
url | String | 网络资源地址 |
responseType | String | 响应类型(默认blob) |
options | * |
file.contentToQrcodeUrl(content)
将内容转为二维码图片
Kind: static method of file
Param | Type |
---|---|
content | any |
money
处理金额
Kind: global constant
money.moneyFixed(num, decimalPlaces, unit)
将分格式化为元,保留两位小数
Kind: static method of money
Param | Type | Description |
---|---|---|
num | Number | String | 金额(分) |
decimalPlaces | Number | 小数位数(默认2位) |
unit | String | 单位(默认为元) |
money.moneyComplete(num)
将元格式化为分,主要用于向服务端传递参数时使用
Kind: static method of money
Param | Type | Description |
---|---|---|
num | * | 金额(元,两位小数) |
money.afterTaxPrice(num, tax)
给c端计算税率
Kind: static method of money
Param | Type | Description |
---|---|---|
num | Number | String | |
tax | Number | 税率(默认值1.0835) |
customStorage
处理本地数据
Kind: global constant
customStorage.setStorage(key, value, isLocal)
本地数据存储
Kind: static method of customStorage
Param | Type | Description |
---|---|---|
key | String | 存储KEY |
value | any | 存储的内容 |
isLocal | Boolean | 是否使用localStorage(默认是),否则使用sessionStorage |
customStorage.getStorage(key, isLocal)
读取本地存储的数据
Kind: static method of customStorage
Param | Type | Description |
---|---|---|
key | String | 需读取的KEY |
isLocal | Boolean | 是否使用localStorage(默认是),否则使用sessionStorage |
transform
处理字符串
transform.hideSomeString(str, start, end, replaceStr)
将字符串指定位置替换为指定字符
Kind: static method of transform
Param | Type | Description |
---|---|---|
str | * | 需替换的字符串 |
start | * | 开始位置(默认0) |
end | * | 结束位置(默认0) |
replaceStr | * | 替换为(默认为*) |