請求一個接口,但是這個接口里面有$ref的字段,內(nèi)容無法正常顯示這是請求到的數(shù)據(jù)..后端說是要把這個字段的值替換成state.downloadCategoryMap重新請求一下就變正常了大家有遇到這種情況的嗎?這是后端給出的處理辦法 ↓↓↓let diguiReflectList = (theObj) => { if (theObj) { if (theObj.children) { theObj.children = theObj.children.map(item => diguiReflectList(item)); } if (theObj["$ref"]) { return eval(theObj["$ref"] .replace("\$.data.downloadCategory", "state.downloadCategoryMap") .replace("\$.data", "state.downloadCategoryMap"));//千萬注意二級路徑的問題 } else { theObj.title = theObj.id; theObj.expand = true; state.downloadCategoryMap[theObj.id] = theObj; return theObj; } } else { return theObj; } };
vue調(diào)用接口出現(xiàn)$ref問題
慕仙森
2019-03-19 17:14:59