接口要的日期格式是 “‘2022-07-01’,‘2022-07-08’,‘2022-07-15’,‘2022-07-22’”
这种双引号包裹单引号逗号分割的格式
使用的是日期组件el-date-picker
提交时转化如下
this.searchData.startdate = "'"+ this.searchData.startdate.join("','") + "'"
但是需要回显所以
this.searchData.startdate = this.searchData.startdate.split(',')
如果不退出页面还可二次提交这时格式就会变化为每一项多一个单引号
又开始有了以下操作格式换回来
if(this.searchData.startdate) {
if(!this.isChangeDate) {
this.searchData.startdate = "'"+ this.searchData.startdate.join("','") + "'"
this.searchData.startdate = this.searchData.startdate.replace(/\'/g, '')
this.searchData.startdate = this.searchData.startdate.split(',')
}
this.isChangeDate =false
this.searchData.startdate = "'"+ this.searchData.startdate.join("','") + "'"
}
转换以后格式正确