码迷,mamicode.com
首页 > 移动开发 > 详细

通俗易懂的axios

时间:2019-09-19 21:38:26      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:err   users   div   ios   axios   ons   params   response   bsp   

get的两种请求:

                methods:{
                    //axios.get的发送参数有两种,两个ajax请求函数都可实现
                    sendGetByStr(){
                        //1.get通过直接发字符串拼接
                        axios.get(`get.php?name=${this.users.name}&age=${this.users.name}`)
.then(
function (response) { console.log(response.data); }) .catch(function (error) { console.log(error); }); }, sendGetByObj(){ //2.get通过params选项 axios.get(`get.php?`,{ params:{ name:this.users.name, age:this.users.age } })
.then(
function (response) { console.log(response.data); }) .catch(function (error) { console.log(error); }); } } })

post的一种

methods:{
                    sendPsot(){

                        axios.post(‘post.php‘, {
                            name: this.users.name,
                            age: this.users.age,
                          })

                          .then(function (response) {
                            console.log(response);
                          })
                          .catch(function (error) {
                            console.log(error);
                          });
                    }
                    
                }

 

通俗易懂的axios

标签:err   users   div   ios   axios   ons   params   response   bsp   

原文地址:https://www.cnblogs.com/ll15888/p/11552352.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!