前言:拼接一个以逗号隔开的字符串,并删除最后一个逗号,代码如下:
var id = ''for(var i=0;i<this.chooseList.length;i++){id+= this.chooseList[i].admin_id + ','}id= id.substring(0,id.length - 1)
传给后端的字段格式是以下这样,代码如下:
data () {return {tim1: '',tim2: '',}},let tim1 = this.tim1 / 1000 === 0 ? '' : this.tim1 / 1000let tim2 = this.tim2 / 1000 === 0 ? '' : this.tim2 / 1000let adds = ''if (tim1 !== '' || tim2 !== '') {let add_date = {start_date: tim1,end_date: tim2}adds = JSON.stringify(add_date)}const query = {invoice_date: adds || '',}