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

在Vue中引入Axios并用来发起Ajax请求在 Vue 工程的 main js 中 引入 axios 并绑定到 this http 中 在 vue 文件的 method 中 编写方法 方法体里边 便可以通过 this http 发起 ajax 请求了

欢迎大家来到IT世界,在知识的湖畔探索吧!

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

欢迎大家来到IT世界,在知识的湖畔探索吧!

一、安装

npm install axios

欢迎大家来到IT世界,在知识的湖畔探索吧!

二、引入

Vue 工程的 main.js 中,引入 axios ,并绑定到 this.$http

欢迎大家来到IT世界,在知识的湖畔探索吧!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) }

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://itzsg.com/117376.html

(0)
上一篇 1小时前
下一篇 1小时前

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

联系我们YX

mu99908888

在线咨询: 微信交谈

邮件:itzsgw@126.com

工作时间:时刻准备着!

关注微信