二级联动:map,for循环一级数据,调用接口获取对象数据依次放到数组里,解决由于后端java是多线程,接收到的数据放入

解决方法1:遍历一级数据时先push一个新的对象,调用接口获取到数据之后splice方法通过index的值判断放入到数组的对应下标下

this.tableData一级数据:

this.relationMaterialNameList二级数据:

this.tableData.map((item,index)=>{

this.relationMaterialNameList.push({})

// 编辑页面项目下拉框数据

this.getSpecificationList(item.reimbursementType, index)

})

// 项目下拉数据

getSpecificationList(code, index) {

// 项目下拉数据

this.$axios({

url: `/chenfan_sample/sampleDevReim/relationMaterial?reimbursementType=${code}`,

method: 'get',

}).then((res) => {

if (res.code === 200) {

this.relationMaterialNameList.splice(index, 1, res.obj)

}

})

},

解决方法2:promise all 是按顺序返回的