function isEmpty(data) {
if (data) {
// 数字不为0,'0' ,字符串不为'',不是null,不是underfind
if (typeof data === 'String') {
if (data === 'null' || data === 'false' || data === '0') {
return false
}
}
if (typeof data === 'object') {
// 对象 null function typeof 不能用来判断数据是 数组、对象 或者是 null
if (Object.prototype.toString.call(data) === '[object Array]' && data.length === 0) {
// 是数组
return true
}
if (Object.prototype.toString.call(data) === '[object Object]' && Object.keys(data).length === 0) {
// 是对象
return true
}
}
return true
}
};