把以下代码改成if()和else if()解构: {lunarDate.cMonth == 1 && [5, 6, 7].includes(lunarDate.cDay) ? term1 = j[0] : null} {lunarDate.cMonth == 2 && [3, 4, 5].includes(lunarDate.cDay) ? term1 = j[1] : null} {lunarDate.cMonth == 3 && [5, 6, 7].includes(lunarDate.cDay) ? term1 = j[2] : null} {lunarDate.cMonth == 4 && [4, 5, 6].includes(lunarDate.cDay) ? term1 = j[3] : null} {lunarDate.cMonth == 5 && [5, 6, 7].includes(lunarDate.cDay) ? term1 = j[4] : null} {lunarDate.cMonth == 6 && [5, 6, 7].includes(lunarDate.cDay) ? term1 = j[5] : null} {lunarDate.cMonth == 7 && [6, 7, 8].includes(lunarDate.cDay) ? term1 = j[6] : null} {lunarDate.cMonth == 8 && [7, 8, 9].includes(lunarDate.cDay) ? term1 = j[7] : null} {lunarDate.cMonth == 9 && [7, 8, 9].includes(lunarDate.cDay) ? term1 = j[8] : null} {lunarDate.cMonth == 10 && [8, 9].includes(lunarDate.cDay) ? term1 = j[9] : null} {lunarDate.cMonth == 11 && [7, 8].includes(lunarDate.cDay) ? term1 = j[10] : null} {lunarDate.cMonth == 12 && [6, 7, 8].includes(lunarDate.cDay) ? term1 = j[11] : null}
时间: 2024-01-24 10:19:27 浏览: 82
if(lunarDate.cMonth == 1 && [5, 6, 7].includes(lunarDate.cDay)) {
term1 = j[0];
} else if(lunarDate.cMonth == 2 && [3, 4, 5].includes(lunarDate.cDay)) {
term1 = j[1];
} else if(lunarDate.cMonth == 3 && [5, 6, 7].includes(lunarDate.cDay)) {
term1 = j[2];
} else if(lunarDate.cMonth == 4 && [4, 5, 6].includes(lunarDate.cDay)) {
term1 = j[3];
} else if(lunarDate.cMonth == 5 && [5, 6, 7].includes(lunarDate.cDay)) {
term1 = j[4];
} else if(lunarDate.cMonth == 6 && [5, 6, 7].includes(lunarDate.cDay)) {
term1 = j[5];
} else if(lunarDate.cMonth == 7 && [6, 7, 8].includes(lunarDate.cDay)) {
term1 = j[6];
} else if(lunarDate.cMonth == 8 && [7, 8, 9].includes(lunarDate.cDay)) {
term1 = j[7];
} else if(lunarDate.cMonth == 9 && [7, 8, 9].includes(lunarDate.cDay)) {
term1 = j[8];
} else if(lunarDate.cMonth == 10 && [8, 9].includes(lunarDate.cDay)) {
term1 = j[9];
} else if(lunarDate.cMonth == 11 && [7, 8].includes(lunarDate.cDay)) {
term1 = j[10];
} else if(lunarDate.cMonth == 12 && [6, 7, 8].includes(lunarDate.cDay)) {
term1 = j[11];
}
阅读全文