Methods
debounce(fn, timeout)
防抖(被调用n次,只运行一次)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
fn |
回调函数 | ||
timeout |
300 | 延时 |
deepCopy(object) → {*}
深复制对象
Parameters:
Name | Type | Description |
---|---|---|
object |
object | array | 被复制的对象 |
Returns:
复制的对象
- Type
- *
getDateString(ts, format) → {string|*}
获取日期字符串
Parameters:
Name | Type | Default | Description |
---|---|---|---|
ts |
Date | string | number | 要转换的时间 | |
format |
string | YYYY-MM-DD | 日期格式 |
Returns:
日期字符串
- Type
- string | *
getDatetimeString(ts, format) → {string|*}
获取时间字符串
Parameters:
Name | Type | Default | Description |
---|---|---|---|
ts |
Date | string | number | 要转换的时间 | |
format |
string | YYYY-MM-DD HH:mm | 日期格式 |
Returns:
时间字符串
- Type
- string | *
getItem(key) → {string}
获取cookie
Parameters:
Name | Type | Description |
---|---|---|
key |
string | 键 |
Returns:
cookie值
- Type
- string
getItem(key) → {string}
获取
Parameters:
Name | Type | Description |
---|---|---|
key |
string | 键 |
- Source:
Returns:
值
- Type
- string
getValueByPath(object, path, defaultValue) → {*}
根据path安全获取值
Parameters:
Name | Type | Description |
---|---|---|
object |
object | 取值的对象 |
path |
string | 属性path |
defaultValue |
* | 默认值 |
Returns:
获取的值
- Type
- *
isType(value, type) → {boolean}
判断类型
Parameters:
Name | Type | Description |
---|---|---|
value |
* | 要判断的对象 |
type |
string | 类型 |
Returns:
- Type
- boolean
isValidDate(date) → {boolean}
合法日期判断
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | 要判断的日期 |
Returns:
是否合法
- Type
- boolean
makeAction(method, type, url, resolve)
制造请求action
Parameters:
Name | Type | Description |
---|---|---|
method |
请求方法: get(默认), post, put等 | |
type |
mutation类型 | |
url |
请求url | |
resolve |
回调函数(可处理数据) |
Returns:
function
parseJSON(string) → {object}
转json
Parameters:
Name | Type | Description |
---|---|---|
string |
string |
Returns:
json对象
- Type
- object
removeItem(key)
清除cookie
Parameters:
Name | Type | Description |
---|---|---|
key |
string | 键 |
removeItem(key)
清除
Parameters:
Name | Type | Description |
---|---|---|
key |
string | 键 |
- Source:
setItem(key, val, days, hours)
设置cookie
Parameters:
Name | Type | Description |
---|---|---|
key |
string | 键 |
val |
string | 值 |
days |
Date | number | 过期时间|过期天数 |
hours |
number | 过期小时数 |
setItem(key, val, days, hours)
设置localStorage函数
Parameters:
Name | Type | Description |
---|---|---|
key |
string | 键 |
val |
string | 值 |
days |
Date | number | 过期时间|过期天数 |
hours |
number | 过期小时数 |
- Source:
swapArrayItems(array, x, y)
互相调换数组项的位置
Parameters:
Name | Type | Description |
---|---|---|
array |
array | 被操作的数组 |
x |
number | 调换索引 |
y |
number | 调换索引 |
throttle(fn, timeout)
节流(被调用n次,只在time间隔时间点运行)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
fn |
回调函数 | ||
timeout |
300 | 延时 |