使用vue-cli做了簡單的項(xiàng)目,其中網(wǎng)絡(luò)請求使用了axios,但是不知道axios的攔截器該怎么掛載到項(xiàng)目上去。假設(shè)我在一個js文件中寫了如下代碼://Addarequestinterceptorthis.axios.interceptors.request.use(function(config){//Dosomethingbeforerequestissentconsole.log('beforesending')returnconfig;},function(error){//DosomethingwithrequesterrorreturnPromise.reject(error);});那么怎樣才能使得它在項(xiàng)目運(yùn)行的時候生效呢?*axios本身已在man.js中引入:importaxiosfrom'axios'Vue.prototype.axios=axios
跪求!在vue-cli中使用axios攔截求解答!
翻翻過去那場雪
2019-08-14 20:09:43