时间:2023-02-06 10:30:56 | 栏目:vue | 点击:次
async submitForm() { var that = this that.allPersonList = [] // 出库信息数组 // 循环 得到 A0000 for (var i = 0; i < that.personList.length; i++) {//循环拿到传过来的对象集合 personList[{},{},.......] // 出库信息 const newOut = { // 关键! 创建一个新对象 A0000: that.personList[i].a0000, // 将循环拿到的属性循环赋值给newOut.A0000 AG8700: that.getUuid(), AG8701: this.outWareList[0], AG8702: this.outWare.AG8702 } that.allPersonList.push(newOut)// 循环赋值好的对象 push到 集合中 }
alert(JSON.stringify(that.allPersonList))---------> 打印的数据格式:
已知数组如下:
currentGood:[{name:'Da',ids:'aaa',pp:'123'},{name:'Cc',ids:'bbb',pp:'456'},{name:'Vv',ids:'ccc',pp:'789'}]
设置另一数组为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);
运行调试结果如下
作用就是把已知的数据,重新挑选