我的if条件需要帮助。
if(userId && !targetId){
// query logic for userid and no targetid
}
else if (!userId && targetId){
// query logic for targeted and no user id
}
现在我该如何写";否则";部分当用户标识和目标标识都存在时的另一个查询逻辑。
您可以简单地标记另一个if-else:
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
}
您可以进行
else
{
if(userId && targetId){ }
}