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

axios

时间:2019-05-03 14:31:02      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:pre   number   response   oca   rip   The   成功   ons   ora   

npm安装

npm install --save axios vue-axios

安装完之后,在你的main.js文件里配置,加上这两句就好

import axios from ‘axios‘
Vue.prototype.$http = axios

然后你读取接口数据的时候,直接就可以这样写,这个跟resource一个样,我那个下面的op,uin之类的都是要传的参数。

this.$http.post(localStorage.getItem("addUrl")+‘/skynet_sync/btsp‘, {
                            "op": "update_card_num",
                            "uin": uin,
                            "protypeId": index,            
                            "cardNumber": parseInt(v)
                        })
                      .then(response=> {
                        //如果接口走成功就执行这里

                      }).catch(function (error) {
                        //接口失败,也就是state不是200的时候,走这里
                      });

好了,搞定!

axios

标签:pre   number   response   oca   rip   The   成功   ons   ora   

原文地址:https://www.cnblogs.com/AlbertP/p/10805033.html

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