我在 js 函数中有一个 js 代码......这包含 if else 条件......它包含相同的功能,唯一的事情是参数更改......
所以唯一不同的是你传递给函数的参数字符串......使用 if/else 调用函数,其余逻辑是相同的......
是否可以调用该函数,其余逻辑相同......
return $(this).each(function () {
if (coffeeId == "showCoffeeId") {
var todayDate = NoteWorklist.getDateTime("appleTime");
value.Year = todayDate.getFullYear();
value.Month = todayDate.getMonth() + 1;
value.Day = todayDate.getDate();
value.today = todayDate;
value.inputDate = todayDate;
} else {
var todayDate = NoteWorklist.getDateTime("orangeTime");
value.Year = todayDate.getFullYear();
value.Month = todayDate.getMonth() + 1;
value.Day = todayDate.getDate();
value.today = todayDate;
value.inputDate = todayDate;
}
});