当前位置: 移动技术网 > IT编程>网页制作>CSS > vue中Axios请求数据教程

vue中Axios请求数据教程

2018年09月13日  | 移动技术网IT编程  | 我要评论

vue中axios请求数据

vue中axios请求数据 进入文件夹根目录运行命令npm install axios --save

在需要用的页面通过import axios(自定义名字) from 'axios'进行引入

使用

var api="地址";                                                                                                                                                                                 axios.get(api).then(function (response) {
             console.log(response);
         }).catch(function (error) {
               console.log(error);
         }).then(function () {
               console.log("执行");
         });

//也可以像ajax那样,这样子写
 axios({
         method:'get',
         url:api,
         }).then(function(response) {
             console.log(response);
         });

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网