<script type="text/javascript"> // 获取当前日期的之后六天日期 日期格式2020-07-23 var today=new Date(); var dateArr=[] for(var i=0;i<7;i++){ var newDate=new Date(today.getTime()+i*1000*60*60*24) var year=newDate.getFullYear() var month=(parseInt(newDate.getMonth())+1)>9?(parseInt(newDate.getMonth())+1):"0"+(parseInt(newDate.getMonth())+1) var day=(newDate.getDate())>9?newDate.getDate():"0"+newDate.getDate() var fullDate=`${year}-${month}-${day}` dateArr.push(fullDate) } console.log(dateArr) </script>