//验证数据是否不为空(空值时返回false,null、undefined、空字符串、空数组、空对象都被设定为空)
export const isNotEmpty = value => {
switch (typeof value) {
case "undefined": {
return false;
}

case "string": {
return value.length !== 0;
}

case "object": {
if (Array.isArray(value)) {
return value.length !== 0;
} else if (value === null) {
return false;
} else {
return Object.keys(value).length !== 0;
}
}

default: {
return true;
}
}
};

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2022-01-12
  • 2022-01-01
  • 2022-02-10
  • 2022-02-04
相关资源
相似解决方案