Open jiaozitang opened 5 years ago
import axios from 'axios'; import store from '../store/index' /*请求之前*/ // Add a request interceptor axios.interceptors.request.use(function (config) { // Do something before request is sent store.commit("is_load",true); return config; }, function (error) { // Do something with request error return Promise.reject(error); }); /*请求之后*/ // Add a response interceptor axios.interceptors.response.use(function (response) { store.commit("is_load",false); return response; }, function (error) { // Do something with response error return Promise.reject(error); }); export const get = (url,params) => axios.get(url, {params: params}) .then(response => { return response.data }) .catch(err =>{ return err }) export const post = (url,params,config) => axios.post(url, params,config) .then(response => { return response.data }) .catch(err =>{ return err })