一、安装
npm install axios
二、引入
在 Vue 工程的 main.js 中,引入 axios ,并绑定到 this.$http 中
async getStudentData() {
const {
data: res
} = await this.$http.get(`http://www.linhongcun.club/student/getAllStudentByPage/${this.studentVO.page}/${this.studentVO.size}`);
this.studentData = res.content;
this.studentVO.total = res.totalElements;
console.log(this.studentVO)
}
三、使用
在 .vue 文件的 method 中,编写方法,方法体里边,便可以通过 this.$http 发起 ajax 请求了!
async getStudentData() {
const {
data: res
} = await this.$http.get(`http://www.linhongcun.club/student/getAllStudentByPage/${this.studentVO.page}/${this.studentVO.size}`);
this.studentData = res.content;
this.studentVO.total = res.totalElements;
console.log(this.studentVO)
}