初始化仓库
This commit is contained in:
28
utils/judge.ts
Normal file
28
utils/judge.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 判断传入的值是否有值(不为null,'',undefined)
|
||||
* 有则返回true,没有则返回false
|
||||
* @param {number | string | object} value
|
||||
* @return boolean
|
||||
*/
|
||||
export function hasValue(value : number | string | { [key: string]: any}):boolean{
|
||||
if(typeof value == 'number' || typeof value == 'string'){
|
||||
if(value != null && value != '' && value != undefined) return true
|
||||
}
|
||||
if(typeof value === 'object'){
|
||||
for(let i in value){
|
||||
if(value[i] != null && value[i] != '' && value[i] != undefined) return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前北京时间
|
||||
* @return
|
||||
*/
|
||||
export function getBeijingTime():string{
|
||||
//获取当前北京时间的时间戳(单位为毫秒)
|
||||
const stamp= new Date().getTime() + 8 * 60 * 60 * 1000;
|
||||
const beijingTime = new Date(stamp).toISOString().replace(/T/, ' ').replace(/\..+/, '').substring(0, 19);
|
||||
return beijingTime
|
||||
}
|
||||
Reference in New Issue
Block a user