这看起来有点繁琐,可以简化也行,新手,谢谢大佬,感谢getChartsData(this.rule).then(res=>{letobj=res.data.data[0];this.compRegion.lineCode=obj.lineCode;this.compRegion.lineCodeName=obj.lineCodeName;this.compRegion.timeRate=obj.timeRate;this.compRegion.performanceRate=obj.performanceRate;this.compRegion.percentRate=obj.percentRate;this.compRegion.deviceRate=obj.deviceRate;this.compRegion.deviceOee=obj.deviceOee;this.compRegion.deviceTeep=obj.deviceTeep;this.compRegion.startRate=obj.startRate;this.compRegion.planRate=obj.planRate;});
2 回答
婷婷同学_
TA贡献1844条经验 获得超8个赞
这样?getChartsData(this.rule).then(res=>{letobj=res.data.data[0];letneedKey=['lineCode','lineCodeName','timeRate','performanceRate','percentRate','deviceRate','deviceOee','deviceTeep','startRate','planRate']needKey.forEach(item=>{this.compRegion[item]=obj[item]})});
慕尼黑8549860
TA贡献1818条经验 获得超11个赞
//解构this.compRegion={...res.data.data[0]}//如果还有一些多余的字段不想带进去可以使用only这库importonlyform'only'//前提this.compRegion有初始属性this.compRegion=only(res.data.data[0],Object.keys(this.compRegion))
添加回答
举报
0/150
提交
取消