产品一张表luckysheet前端代码库
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.

36 lines
707 B

5 years ago
/**
* Common tool methods
*/
/**
* Determine whether a string is in standard JSON format
* @param {String} str
*/
function isJsonString(str) {
try {
if (typeof JSON.parse(str) == "object") {
return true;
}
} catch (e) { }
return false;
}
/**
* Determine whether a variable is a pure number, null/""/undefined/"34rt"/"34e" is not a number, 34/"34"/"34e10" is a number
* @param {Number | String | } val
*/
function isRealNum(val) {
if (val == null || val.toString().replace(/\s/g, "") === "") {
return false;
}
if (!isNaN(val)) {
return true;
} else {
return false;
}
}
export {
isJsonString,
isRealNum
}