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