I've seen similar questions here, but I can't quite figure out how to silence this error for my case with several conditions involved.
This is the .filter()
object:
orders.filter((order) => {
if (filterId === 0) {
return order.status === 0 && order.type <= 3;
} else if (filterId === 1) {
return order.status === 0 && order.type === 0;
} else if (filterId === 2) {
return order.status === 0 && order.type === 1;
} else if (filterId === 3) {
return order.status === 0 && order.type === 2;
}
}).map(...);
consider switch your approach to switch instead chain of if else.
orders.filter((order) => { let value = 0; switch(filtedId){ case 0: value = order.status === 0 && order.type <= 3; case 1: value = order.status === 0 && order.type === 0; case 2: value = order.status === 0 && order.type === 1; case 3: value =order.status === 0 && order.type === 2; default: value = 0 } return value }).map(...);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.