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('空字符')
}
空字符串等价于逻辑假,所以直接判断即可:var s=""
if(s){
//s不是空字符串
}else{
//s是空字符串
}