vue中axios数据请求 get和post
2018-12-19 16:20
363 查看
axios(基于 promise 的 HTTP 库)
<script src="./vue.js"></script> <!-- 1. 引入axios文件 --> <script src="./axios.js"></script> <script> let vm = new Vue({ el: '#app', data: { newId: '', newName: '', list: [], }, // get 请求 methods: { getList() { let url = 'http://19list.........' // 调用axios的get方法,获取数据 axios.get(url) .then(res => { console.log(res); // 将获取回来的数据赋值给list this.list = res.data }) .catch(err => { console.log(err); }) }, } // post 请求 methods: { getData: function () { var url = 'http://www.liulongbin.top:3005/api/addproduct' axios.post(url, "name=hello") .then(res => { console.log(res); }) .catch(error => { console.log(error); }) } } }) </script>
相关文章推荐
- vue中axios处理http发送请求的示例(Post和get)
- vue开发:axios的post请求接口出现404,但是get则成功
- ios开发系列之Get与Post方式请求数据
- iOS 网络请求数据两种请求方式GET,POST
- iOS 数据请求 get、post
- vue请求方式axios和axios.get
- iOS基础8:自定义MyData/自定义SQLite用于网络判断,版本判断,图片缓存处理,下载或者上传的GET或POST请求,加密手段,.数据解析
- vue中的所有axios请求都会发送2次,但是第一次不返回数据的原因
- iOS-使用NSURLConnection进行Http Get和Post请求网络数据
- iOS 网络请求数据 同步请求、异步请求、GET、POST请求
- vue中axios的封装问题(简易版拦截,get,post)
- iOS 数据请求 同步get 同步post 异步get 异步post
- ios之NSURLConnection网络请求数据/GET与POST方法
- iOS中GET 和 POST 数据请求
- iOS请求数据两种方式(GET、POST)
- IOS中网络数据请求过程详解(GET POST方法使用)
- iOS中GET 和 POST 数据请求
- vue通过axios发送put/post等请求,配合后台consume"MediaType.APPLICATION_FORM_URLENCODED"
- vue-resource、Vue中response的get、post和jsonp请求例子
- IOS之同步请求、异步请求、GET请求、POST请求