JS 判断字符串是否为空

打杂的 Be 主前端后端都写 哭唧唧

function isEmpty(str) {
    if(typeof str== null || str== "" || str== "undefined") {
        return true;
    } else {
        return false;
    }
}

  

if(isEmpty(ind_vue.params.userId)) {
    console.log("userId");
}
if(isEmpty(ind_vue.params.dayStart)) {
    console.log("dayStart");
}
if(isEmpty(ind_vue.params.dayEnd)) {
    console.log("dayEnd");
}
if(isEmpty(ind_vue.params.timeStart)) {
    console.log("timeStart");
}
if(isEmpty(ind_vue.params.timeEnd)) {
    console.log("timeEnd");
}

  

猜你喜欢

转载自www.cnblogs.com/zlrrrr/p/11465940.html