2022
09-03
09-03
JavaScript axios安装与封装案例详解
1.下载axios插件cnpminstallaxios-S2.在main.js引入axiosimportaxiosfrom'axios'Vue.prototype.$http=axios3.创建axios实例letservice=axios.create({baseURL:baseUrl,//url=baseapiurl+requesturlwithCredentials:true,//sendcookieswhencross-domainrequeststimeout:5000//requesttimeout})4.请求拦截letloading;//请求拦截service.interceptors.request.use(config=>{//...
继续阅读 >