基本使用
Axios.method('url',[,..data],options) .then(function(res){ }) .catch(function(err) { } )
合并請求
-
this.$axios.all([請求1,請求2]) .then( ?this.$axios.spread(function(res1,res2){ ?}) )
攔截器
-
單請求配置options:
axios.post(url,data,options);
-
全局配置defaults:
this.$axios.defaults
-
config :
請求攔截器中的參數
-
response.config
響應攔截器中的參數
-
options
-
baseURL 基礎URL路徑
-
params 查詢字符串(對象)
-
transformRequest 轉換請求體數據
-
transformResponse 轉換響應體數據
-
headers 頭信息
-
data 請求體數據
-
timeout 請求超時,請求多久以后沒有響應算是超時(毫秒)
-