problem description
how do you decide whether to include this node based on a value when constructing a json in js?
the environmental background of the problems and what methods you have tried
of course you can do it with a lot of if, such as
let req = {};
if(this.timeSelect.start != ""){
req.startTs = this.timeSelect.start;
}
if(this.timeSelect.end != ""){
req.endTs = this.timeSelect.end;
}
if(this.userId != ""){
req.userId = this.userId;
}
if(this.auditType != "1"){
req.checkType = this.auditType;
}
if(this.opter != ""){
req.operator = this.opter;
}
if(this.auditStatus != "0"){
req.result = this.auditStatus ;
}
what result do you expect? What is the error message actually seen?
do the gods have any good and simple ways?