AXios接受XML格式的webservice并解析成数据格式
import axios from "axios"; let _env = import.meta.env let url1 = _env.VITE_APP_BASE_API let url2 = _env.VITE_APP_zhuang_API async function map(){ let a=[] let d let code await axios({ method: 'get', url: url1, headers: { 'Content-Type': 'text/xml' } }).then(res=>{ //调用axios自己封装的接口 a=res.data console.log(a) var pattern=/Value=(.*) Date/i code=pattern.exec(a); d = parseInt(code[1].replace(/\"/g, "")); }) return d } const b=await map() //结果正确返回a console.log(b); const mockData = { // 横向柱形图 regionData: { regions: [ { id: 1, name: "华北", value: b }, { id: 2, name: "东北", value: utils.createRandom(1, 100) }, { id: 3, name: "华东", value: utils.createRandom(1, 100) }, { id: 4, name: "中南", value: utils.createRandom(1, 100) }, { id: 5, name: "西南", value: utils.createRandom(1, 100) }, { id: 6, name: "西北", value: utils.createRandom(1, 100) }, ] },