在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ axios可以單獨做請求攔截嗎?

axios可以單獨做請求攔截嗎?

axios可以單獨做請求攔截嗎?

比如,我發(fā)送登錄請求,接收請求前加一個單獨的loading動畫這樣。

回答
編輯回答
背叛者

你可以在調用axios發(fā)送請求之前加載loading動畫,請求結束后結束動畫。

2017年6月29日 00:47
編輯回答
裸橙

可以使用 Interceptors

拿 loading 來講,代碼大概長這樣:

axios.interceptors.request.use(function (config) {
  // 開啟 loading
  startLoading()
  return config
});

axios.interceptors.response.use(function (response) {
  // 關閉 loading
  endLoading()
  return response
})
2018年6月18日 19:46