在Vue中引入Axios并用来发起Ajax请求

  • 时间:2025-11-15 20:02 作者: 来源: 阅读:0
  • 扫一扫,手机访问
摘要:一、安装npm install axios二、引入在 Vue 工程的 main.js 中,引入 axios ,并绑定到 this.$http 中async getStudentData() { const { data: res } = await this.$http.get(`http://www.linhongcun.club/student/getAllSt

在Vue中引入Axios并用来发起Ajax请求

一、安装

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)
}
  • 全部评论(0)
最新发布的资讯信息
【系统环境|】Office 2010 自带公式编辑器的公式字体怎么修改?(2025-11-15 22:07)
【系统环境|】PGC世界赛 A组队伍概览 #绝地求生(2025-11-15 22:07)
【系统环境|】讲透 Spring Boot Cloud(2025-11-15 22:06)
【系统环境|】Dubbo和SpringCloud区别详解(4大核心区别)(2025-11-15 22:06)
【系统环境|】Spring Boot3 中实现全链路追踪,你 get 了吗?(2025-11-15 22:05)
【系统环境|】SpringCloud最全详解(万字图文总结)(2025-11-15 22:05)
【系统环境|】爆了爆了,Spring Cloud面试题(2025-11-15 22:04)
【系统环境|】一文部署skywalking(2025-11-15 22:03)
【系统环境|】使用Qt实现一个简单的绘图软件(2025-11-15 22:03)
【系统环境|】用Python做科学计算(工具篇)——scikit-learn(机器学习)2(2025-11-15 22:02)
手机二维码手机访问领取大礼包
返回顶部