2017-08-07 92 views
2

现在我用爱可信这样的:爱可信设置配置VUE JS头

import axios from 'axios' 
axios.get(apiObjUrl, 
    { 
    headers: { 
       'Content-type': 'application/x-www-form-urlencoded', 
       } 
    }) 
    .then(({data}) => { 

如何设置全局爱可信头? (我需要设置本地化头在我所有的请求使用)

回答

0

使用了爱可信拦截:https://github.com/mzabriskie/axios#interceptors

config你请求的报头。

+0

你能提供一个使用拦截器的例子吗? – user2950593

+0

axios.interceptors.request.use(函数(配置){// 做一些请求被发送回 之前的配置; },功能(错误){// 不要放弃请求错误的东西 返回Promise.reject(错误); }); – user2950593