npm i @axmine/helper -S
// ts
import { cookie } from '@axmine/helper/lib/cookie';
// js
import helper from '@axmine/helper';
var helper = require('@axmine/helper');
<script src="helper.js"></script>
名称 | 用途 | 说明 | 返回值 |
---|---|---|---|
cookie.set( key: string, value: any, expireDays: number ) |
存储cookie | expireDays单位为天数 | boolean |
cookie.get(key: string) | 取出cookie | -- | boolean |
cookie.remove(key: string) | 删除cookie | -- | boolean |
new Storage( type: 'localStorage'|'sessionStorage' = 'localStorage' ) |
同cookie的方法 | -- | 同上 |
random( min: number = 0, max: number = 1, result: 'float'|'int' = 'float' ) |
取随机数 | result为 int 时 只返回随机的整数 |
number |
getType(data:any) | 获取参数的类型 | -- | string |
date.format( data: number|string, format: string = 'y-m-d h:i' ) |
通过时间戳返回日期 或 通过日期返回时间戳 |
data为数字时,必须为秒数,不支持毫秒 data为字符串时,必须为规范的日期字串 |
string | number |
2021.04.07:
- 主要语言已转至typescript,用ts把要用的主要方法都重写了
// 打包
npm run build
// 测试
npm run test
MIT