1.0.0 • Published 4 years ago
dfdz-utils v1.0.0
dfdz-utils v1.0.0
简介
将一些js小功能,整合在一起。
安装
npm install dfdz-utils -S
快速使用
1、lodash
import D from 'dfdz-utils';
D.lodsh.isNumber(111)
更多的用法,可以去lodash的官网去查看
2、moment
import D from 'dfdz-utils';
D.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
更多的用法,可以去moment的官网去查看,PS:helper函数里基于moment封装了一个时间格式化,平时可以优先使用那个
3、helper
import D from 'dfdz-utils';
时间格式化:D.helper.dateFormat(new Date(),'YYYY-MM-DD'),格式如果不传就是'YYYY-MM-DD HH:mm:ss',
浮点型保留小数:D.helper.toFixed(1213,2),
dateFormat的具体用法,跟moment一样,只不过是基于moment做了一个常用的二次封装
4、storage
storageValue : Object
临时存储的变量
Kind: global constant
setStorage ⇒ boolean
存储本地数据
Kind: global constant
Param | Type | Description |
---|---|---|
key | string | 数据名 |
value | * | 值 |
expire | number | Date | 过期时间,不传或0,表示永不过期 |
getStorage ⇒ *
获取本地数据
Kind: global constant
Param | Type | Description |
---|---|---|
key | string | 数据名 |
keepStorage
给localStorage续期
Kind: global constant
Param | Type | Description |
---|---|---|
key | string | 数据名 |
expTime | number | Date | 过期时间 |
removeStorage ⇒ boolean
删除本地数据
Kind: global constant
Param | Type | Description |
---|---|---|
key | string | 数据名 |
clearStorage
清空本地数据
Kind: global constant
update()
更新localStorage
Kind: global function
isExpired(expire) ⇒ boolean
判断是否已过期
Kind: global function
Param | Type |
---|---|
expire | number |
5、classNames
react官方推荐的classnames库 说明文档: https://github.com/JedWatson/classnames
1.0.0
4 years ago