vue set a global variable, specified request baseurl

A basic environment
the front
vue: 2.5.6
Axios: 0.18
Use vue scaffolding to build the project. Referring: webstorm building project vue
background
ssm frame
front and rear ends json format data transmission using
two distal configuration.
Axios Configuration
1. Install: npm install axios --save

2. Introduction of a desired component in axios:

 

axios import from  ' axios ' ;

 

Configuration parameters axios <script> in

const myaxios = Axios // not across domains Axios
 // if you want to cross-domain, then to Axios some settings, the currently used cross-domain 
const axiosInstance = axios.create ({
    headers: { ' the Content-the Type ' : ' file application / JSON; charset = UTF-. 8 ' }, // set the transmission type and content encoding 
    withCredentials: to true , // specifies a request should be sent credentials. It allows the client to carry the cross-domain cookie, but this configuration requires 
});

 

 

 

 

Guess you like

Origin www.cnblogs.com/jasonLiu2018/p/11991197.html