// 处理日期'2020年3月19日'->'2020-3-19' function dealDateToStr(dealDate) { let split_1 = dealDate.split('年'); let year = split_1[0]; let split_2 = split_1[1].split('月'); let month = ''; if (split_2[0].length < 2) { month = '0' + split_2[0] } else { month = split_2[0] } let split_3 = split_2[1].split('日'); let day = ''; if (split_3[0].length < 2) { day = '0' + split_3[0] } else { day = split_3[0] } return year + '-' + month + '-' + day } // 处理日期'2020-3-19'->'2020年3月19日' function dealStrToDate(dealDate) { let split_1 = dealDate.split('-'); let year = split_1[0]; let month = split_1[1]; let day = split_1[2]; if (new RegExp("^0").test(month)) { month = month[1] } if (new RegExp("^0").test(day)) { day = day[1] } return year + '年' + month + '月' + day + '日' }