vue-axios中文网:http://www.axios-js.com/zh-cn/docs/vue-axios.html安装npm install --save axios vue-axios将下面代码加入入口文件import Vue from vueimport axios from axiosimport VueAxios from v...
vue-axios中文网:http://www.axios-js.com/zh-cn/docs/vue-axios.html
安装
npm install --save axios vue-axios
将下面代码加入入口文件
import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios)
发送axios请求
- get请求
this.axios({
method: "get",
url: "http://localhost:8081/user/regist?name="+this.username+"&age="+this.age,
}).then(function (response) {
console.log(response.data);
});
- post请求
this.axios({
method: "post",
url: "http://localhost:8081/user/regist",
data:{
username:this.username,
age:this.age
}
}).then(function (response) {
console.log(response.data);
});
编程基础网
本文标题为:vue-axios的使用
基础教程推荐
猜你喜欢
- 以代码实例总结iOS应用开发中数据的存储方式 2022-11-20
- iOS的音频文件的格式转换示例 2023-06-11
- iOS微信分享后关闭发送成功提示并返回应用 2023-01-03
- iOS对数组进行排序的实例代码 2023-03-16
- Kotlin的枚举与异常示例详解 2022-12-07
- Android自定义悬浮按钮效果 2023-04-22
- 使用Android Studio创建OpenCV4.1.0 项目的步骤 2023-02-26
- iOS统计项目的代码总行数 2022-11-01
- Android自定义view实现圆形进度条效果 2023-05-26
- Android zxing如何识别反转二维码详解 2022-11-08
