Commit 76b156fd by haojie

更新数据类型校验方法

parent 10024fae
...@@ -143,10 +143,14 @@ export const isDev = () => { ...@@ -143,10 +143,14 @@ export const isDev = () => {
}; };
// 判断数据类型 // 判断数据类型
export const DataType = (value: any, key: 'array' | 'string' = 'array') => { export const DataType = (value: any, key: 'array' | 'string' | 'object' = 'array') => {
const toString = Object.prototype.toString; const toString = Object.prototype.toString;
if (key == 'array') { if (key == 'array') {
return toString.call(value) === '[object Array]'; return toString.call(value) === '[object Array]';
} else if (key == 'string') {
return toString.call(value) === '[object String]';
} else if (key == 'object') {
return toString.call(value) === '[object Object]';
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment