1.安装axios
npm install --save axios vue-axios
2.在main.js中引入
import axios from 'axios'
Vue.prototype.axios = axios;
// 将axios挂载到prototype上,在组件中可以直接使用this.axios访问
3.在main.js中引入接口地址
Vue.prototype.serverURL = 'http://10.3.12.34:8081';
4.在对应需要的组件中的methods中定义一个方法
getSchool() {
let that = this;
let url = that.serverURL + '/operation/salesIssueBank/getList?type=2';
let params = {
};
that.axios.get(url, {
params:params
}).then(
function (response)