我的if条件需要帮助。
if(userId && !targetId){
// query logic for userid and no targetid
}
else if (!userId && targetId){
// query logic for targeted and no user id
}
现在我该如何写"else“部分呢?当用户id和目标id都存在时的另一个查询逻辑。
发布于 2020-07-21 05:44:37
你可以简单地添加另一个if:
if (userId && !targetId) {
// query logic for userid and no targetid
}
else if (!userId && targetId) {
// query logic for targeted and no user id
}
else if (userId && targetId) {
// query logic for both true
}
else {
// this defaults to both being false, the other three
// conditions already being handled above
}
发布于 2020-07-21 05:45:28
你可以这样做
else
{
if(userId && targetId){ }
}
https://stackoverflow.com/questions/63008080
复制相似问题