You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
636 B
25 lines
636 B
/*
|
|
全局共享实用方法 shared.js
|
|
*/
|
|
|
|
// 判断对错/是否显示,万能校验
|
|
export function isRight(obj) {
|
|
if (isValueType(obj) === 'string') {
|
|
obj = obj.trim();
|
|
if (obj === 'null' || obj === 'undefined') {
|
|
return false;
|
|
}
|
|
} else if (isValueType(obj) === 'number' && (isValueType(obj) === "number" && !isNaN(obj)) && obj !== 0) {
|
|
return true;
|
|
}
|
|
for (var key in obj) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// 判断一个值所属的类型,返回一个字符串
|
|
export function isValueType(value) {
|
|
let str = Object.prototype.toString.call(value);
|
|
return str.match(/\[object (.*?)\]/)[1].toLowerCase();
|
|
}
|