Methods
# ajax(url, data, method) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
url |
String
|
Request address |
data |
Object
|
Request parameters |
method |
String
|
Request way get/post |
Promise
# checkBankCard(bankCard) → {Boolean}
Parameters:
Name | Type | Description |
---|---|---|
bankCard |
String
|
Bank card number |
Boolean
# checkPassword(password) → {Boolean}
Parameters:
Name | Type | Description |
---|---|---|
password |
String
|
password |
Boolean
# checkPhone(phone, isChina) → {Boolean}
Parameters:
Name | Type | Description |
---|---|---|
phone |
String
|
phone number |
isChina |
Boolean
|
Is it a Chinese mobile phone number? |
Boolean
# checkPhoneSystem()
# deepClone(obj) → {Object}
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object
|
Objects to copy |
Deep copy of the object
Object
# fetch(url, setting) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
Request address |
setting |
string
|
Request configuration |
Request promise
Promise
# getObjectLength(obj)
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object
|
To get an object of the number of properties |
# getScrollTop() → {Number}
Get the distance from the top of the scroll bar
The distance from the top of the scroll bar
Number
# isContain(arr, value)
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array
|
Array to be judged |
value |
any
|
To determine the value |
# mergeArrays(array1, array2) → {Array}
Parameters:
Name | Type | Description |
---|---|---|
array1 |
Array
|
The first array to merge. |
array2 |
Array
|
The second array to merge. |
The merged array.
Array
# shallowClone(obj) → {Object}
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object
|
Objects to copy |
Shallow copy of the object
Object
# sortBy(arr, key, order)
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array
|
Array to be sorted |
key |
String
|
Sort KEY |
order |
String
|
Sort mode, ASC ascending, DESC descending |
Example
sortBy([{name: 'a'}, {name: 'b'}], 'name', 'asc')
// => [{name: 'a'}, {name: 'b'}]
sortBy([{name: 'a'}, {name: 'b'}], 'name', 'desc')
// => [{name: 'b'}, {name: 'a'}]
sortBy([{name: 'a'}, {name: 'b'}], 'name')
// => [{name: 'a'}, {name: 'b'}]
# timeFormat(time) → {*}
Parameters:
Name | Type | Description |
---|---|---|
time |
*
|
Timestamp |
Time format X days ago
*
Example
console.log(timeFormat(1588888888)); // 2 days ago
# trim(str, type) → {string}
Parameters:
Name | Type | Description |
---|---|---|
str |
string
|
String |
type |
string
|
Type 1: All space type 2: front and rear space type 3: Front space type 4: rear |
String
string
# unique(arr) → {Array}
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array
|
Array to be heavy |
Array
Example
console.log(unique([1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10])) // [1,2,3,4,5,6,7,8,9,10]
# windowResize(downCb, upCb) → {function}
H5 soft keyboard is retracted, bounce back When the software keyboard pops up will change the current Window.innerHeight, monitor this value change
Parameters:
Name | Type | Description |
---|---|---|
downCb |
function
|
When the soft keyboard bounces, the retracted callback |
upCb |
function
|
When the soft keyboard bounces |
function