switch (data) { case "一年": myDate.setFullYear(myDate.getFullYear() + 1); etime = myDate.toLocaleDateString(); break; case "半年": myDate.setMonth(myDate.getMonth() + 6); etime = myDate.toLocaleDateString(); break; case "季度": myDate.setMonth(myDate.getMonth() + 3); etime = myDate.toLocaleDateString(); break; } 判断选择的是那个, 然后重新给结束时间赋值