第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

大佬們遇到過這個(gè)問題嗎?js怎么遍歷給對(duì)象賦值

大佬們遇到過這個(gè)問題嗎?js怎么遍歷給對(duì)象賦值

慕森王 2019-10-25 23:14:40
這看起來有點(diǎn)繁瑣,可以簡(jiǎn)化也行,新手,謝謝大佬,感謝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貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個(gè)贊

這樣?
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]
})
});
                            
查看完整回答
反對(duì) 回復(fù) 2019-10-25
?
一只甜甜圈

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超5個(gè)贊

//解構(gòu)
this.compRegion={...res.data.data[0]}
//如果還有一些多余的字段不想帶進(jìn)去可以使用only這庫
importonlyform'only'
//前提t(yī)his.compRegion有初始屬性
this.compRegion=only(res.data.data[0],Object.keys(this.compRegion))
                            
查看完整回答
反對(duì) 回復(fù) 2019-10-25
  • 2 回答
  • 0 關(guān)注
  • 281 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)