Vue with axios implementation calls and back-end Java

Install axios: npm install axios

Reintroduced into the configuration in FIG. Main.js in:

import axios from 'axios'

Vue.prototype. $ Ajax = axios

// axios Configuration

axios.defaults.timeout = 5000;

//axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';

axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';

// axios.defaults.headers.post['Content-Type'] = 'json';

// axios.defaults.baseURL = 'http: // localhost: 8080 / project name /';

axios.defaults.baseURL = 'http://localhost:3682/';

vue Add code page:

Renderings:

Java backend interfaces:

Vue run the project, call interface

Released five original articles · won praise 1 · views 10000 +

Guess you like

Origin blog.csdn.net/star_zone/article/details/82784086