import axios from 'axios'; const http_url = "https://xxx.xxx.com" // get请求 export function getRequest(url, sendData) { return new Promise((resolve, reject) => { axios.get(http_url + url, {params: sendData}).then(res => { resolve(res.data); }).catch(error => { reject(error); }) }) } // post请求 export function postRequest(url, sendData) { return new Promise((resolve, reject) => { axios.post(http_url + url, sendData).then(res => { resolve(res.data); }).catch(error => { reject(error); }) }) }
标签:sendData,axios,封装,url,res,resolve,reject From: https://www.cnblogs.com/wuyongcong/p/17631818.html