//引入axios import axios from 'axios' //引入qs import qs from 'qs' //根URl const rootUrl = '' //axios请求实例 function https(url, method, data, params, success, err) { console.log(url); axios({ method: method, url: url, data: qs.parse(data), baseURL: rootUrl, headers: { 'Content-Type': 'application/json' }, params: params, timeout: 10000, withCredentials: false }).then(res => { if (res.status == 200) { success(res.data) } }).catch(function (error) { console.log(error); }); } //导出方法 export default ({ get: function (url, data, params, success, err) { https(url, 'get', data, params, success, err); }, post: function (url, data, params, success, err) { https(url, 'post', data, params, success, err); } })
标签:axios,err,success,url,配置,params,data From: https://www.cnblogs.com/zhang-3/p/18101071