• 验证数据是否不为空(空值时返回false,null、undefined、空字符串、空数组、空对象都被设定为空)


    //验证数据是否不为空(空值时返回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;
    }
    }
    };

  • 相关阅读:
    rebar
    namenode ha
    jmx
    doclint in jdk8
    maven source
    avd
    ccw-ide
    ST3使用
    Web worker
    离线web-ApplicationCache
  • 原文地址:https://www.cnblogs.com/aisiqi-love/p/11394377.html
Copyright © 2020-2023  润新知