1.npm install --save axios
2.在main.js里面引入import axios from ‘axios’
3.在main.js中加到vue的原型上Vue.prototype.axios =axios;
4.使用的时候直接this.axios
5.多个请求一起的时候
async fetchData() {
axios.all([fetchCompanyCard({
belongMonth: this.rowData.belongMonth,
belongYear: this.rowData.belongYear,
creditNo: this.rowData.creditNo
}),
fetchCompanyManager({
belongMonth: this.rowData.belongMonth,
belongYear: this.rowData.belongYear,
creditNo: this.rowData.creditNo
})
]).then(axios.spread((cardData, managerData) => {
this.cardData = cardData
this.managerData = managerData
})).catch(() => {
});
},