判断某个字符是否为空(常用方法)

// 判断某个字符是否为空
    isEmpty(obj){
    if(obj == 0) obj = obj.toString();
if(typeof obj == "undefined" || obj == null || obj == "" || obj.length == 0){ return obj; }else{ return false; } },

 更新:

export default{
    isEmpty:(obj)=>{
        if (obj == 0) obj = obj.toString();
        if (
            typeof obj == "undefined" ||
            obj == null ||
            obj == "" ||
            obj.length == 0 ||
            Object.keys(obj).length == 0
        ) {
            return true;
        } else {
            return false;
        }
    },    
}

 

posted @ 2020-11-23 09:31  小那  阅读(379)  评论(0编辑  收藏  举报