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 str = "任意 字符串"if (str.indexOf(" ") == -1) {
alert("没有空格")
} else {
alert("有空格")
}