解決方法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 是按順序返回的
