同一接口不同条件下传参字段不同 Dilys.Lyu 2021年10月27日 约 84 字 预计阅读 1 分钟 次阅读 目录 同一接口不同条件下传参字段不同 同一接口不同条件下传参字段不同 解决方法:把相同字段封装为一个对象,不同字段封装一个对象,最后组合为一个对象传给接口 1 2 3 4 5 6 7 8 9 10 const differParams = { "year":{year:this.time}, "month":{year:this.time.substring(0,4),endMonth:this.time.substring(4)*1}, "quarter":{year:this.time.substring(0,4),quarter:this.time.substring(4)*1} } const sameParams = {type:this.kind,code:this.code} const params ={...sameParams,...differParams[this.kind]} await getList(params) Please enable JavaScript to view the comments powered by Valine.