feat:增加工具方法
This commit is contained in:
parent
bfab2191a7
commit
044ab5ea4c
@ -17,7 +17,7 @@ export function isNull(val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isObject(val) {
|
export function isObject(val) {
|
||||||
return !isNull(isNull) && is(val, 'Object')
|
return !isNull(val) && is(val, 'Object')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isArray(val) {
|
export function isArray(val) {
|
||||||
@ -80,6 +80,17 @@ export function isEmpty(val) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 类似sql的isnull函数
|
||||||
|
* * 第一个参数为null/undefined/''则返回第二个参数作为默认值,否则返回第一个参数
|
||||||
|
* @param {Number|Boolean|String} val
|
||||||
|
* @param {Number|Boolean|String} replaceVal
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function isNullReplace(val, replaceVal = '') {
|
||||||
|
return isNullOrUndef(val) || val === '' ? replaceVal : val
|
||||||
|
}
|
||||||
|
|
||||||
export function isUrl(path) {
|
export function isUrl(path) {
|
||||||
const reg =
|
const reg =
|
||||||
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/
|
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/
|
||||||
|
Loading…
Reference in New Issue
Block a user