vue如何循環(huán)給對(duì)象賦值
循環(huán)給對(duì)象賦值
async submitForm() {
var that = this
that.allPersonList = [] // 出庫信息數(shù)組
// 循環(huán) 得到 A0000
for (var i = 0; i < that.personList.length; i++) {//循環(huán)拿到傳過來的對(duì)象集合 personList[{},{},.......]
// 出庫信息
const newOut = { // 關(guān)鍵! 創(chuàng)建一個(gè)新對(duì)象
A0000: that.personList[i].a0000, // 將循環(huán)拿到的屬性循環(huán)賦值給newOut.A0000
AG8700: that.getUuid(),
AG8701: this.outWareList[0],
AG8702: this.outWare.AG8702
}
that.allPersonList.push(newOut)// 循環(huán)賦值好的對(duì)象 push到 集合中
}
alert(JSON.stringify(that.allPersonList))---------> 打印的數(shù)據(jù)格式:

把已知數(shù)組循環(huán)賦值給另一數(shù)組
已知數(shù)組如下:
currentGood:[{name:'Da',ids:'aaa',pp:'123'},{name:'Cc',ids:'bbb',pp:'456'},{name:'Vv',ids:'ccc',pp:'789'}]
設(shè)置另一數(shù)組為modeDetail[]
? ? ? for (let i=0;i<this.currentGood.length;i++){
? ? ? ? let modelItem={};
? ? ? ? modelItem["id"]=this.currentGood[i].ids;
? ? ? ? modelItem["name"]=this.currentGood[i].name;
? ? ? ? modelItem["tele"]=this.currentGood[i].pp;
? ? ? ? modeDetail[i]=modelItem;
? ? ? }
? ? ? console.log(modeDetail);運(yùn)行調(diào)試結(jié)果如下

作用就是把已知的數(shù)據(jù),重新挑選
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue 如何實(shí)現(xiàn)配置@絕對(duì)路徑
這篇文章主要介紹了vue 如何實(shí)現(xiàn)配置@絕對(duì)路徑,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09
vue2+el-menu實(shí)現(xiàn)路由跳轉(zhuǎn)及當(dāng)前項(xiàng)的設(shè)置方法實(shí)例
這篇文章主要介紹了vue2+el-menu實(shí)現(xiàn)路由跳轉(zhuǎn)及當(dāng)前項(xiàng)的設(shè)置,方法實(shí)例代碼詳解,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-11-11
vue-router vuex-oidc動(dòng)態(tài)路由實(shí)例及功能詳解
這篇文章主要為大家介紹了vue-router vuex-oidc動(dòng)態(tài)路由實(shí)例及功能詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11
vue-cli3配置多項(xiàng)目并按項(xiàng)目分別實(shí)現(xiàn)打包
這篇文章主要介紹了vue-cli3配置多項(xiàng)目并按項(xiàng)目分別實(shí)現(xiàn)打包方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-01-01
使用vue3實(shí)現(xiàn)element-plus的主題切換效果
Vue3 Element Plus是一個(gè)基于Vue 3框架的UI組件庫,它是由Element UI團(tuán)隊(duì)開發(fā)的升級(jí)版本,Element Plus延續(xù)了Element UI簡(jiǎn)潔、高效的風(fēng)格,并引入了一些新的設(shè)計(jì)語言和技術(shù),如響應(yīng)式API和更好的性能優(yōu)化,本文給大家介紹了如何使用vue3實(shí)現(xiàn)element-plus的主題切換效果2024-12-12

