美文网首页
Js如何判断字符串是否位空格/多空格

Js如何判断字符串是否位空格/多空格

作者: laogui_ | 来源:发表于2020-04-01 18:02 被阅读0次

    //判断字符是否为空的方法
    isEmpty(obj){
    var regu = "^[ ]+$";
    var re = new RegExp(regu);
    if(typeof obj == "undefined" || obj == null || obj == "" || re.test(obj)){
    return true;
    }else{
    return false;
    }
    },
    用法:
    if(this.isEmpty(this.keyword)){
    console.log('空字符')
    }

    相关文章

      网友评论

          本文标题:Js如何判断字符串是否位空格/多空格

          本文链接:https://www.haomeiwen.com/subject/wtgauhtx.html