慕的地10843
报告楼上,这个不归axios管这个归 promise 管,要想代码好看,条件允许的情况下,使用 async 和await还有楼主,代码随便改的,不一定完全正确,但就是这么个意思function parseHtml(url, fun) { return new Promise((resolve,reject)=>{ $.get(url, function(response, state, xhr) { if (state === "success" && xhr.status === 200) { let html = response.substring(response.indexOf("<body"), response.indexOf("</body>") + 7); html = html.trim().replace(/^\<body*?>/, "").replace(/\<\/body\>$/, ""); resolve(html); } else { reject('some error') } }); }}async function eCollapseSourceComputed() {let source = this.eCollapseSource, // 这是一个对象 arr = [];const self = this, // 需要请求的字段 needQuest = ["attachUrl", "content"];source.map(function(val) { let obj = {}; needQuest.map(function(field) { let url = val[field]; if (url && typeof url === "string") { // 问题出在这儿 let val= await parseHtml(url); } }); arr.push(Object.assign(val, obj));});// 返回的数据没有请求到的数据return arr;