安装

cnpm i axios --save-dev

在项目main.js中全局引用

import axios from "axios"
Vue.prototype.$http=axios;

接下来就可以在项目中通过this.$http使用啦,then函数表示响应成功,catch表示失败

      this.$http({
url:"https://api.api68.com/klsf/getLotteryInfo.do?issue=&lotCode=10009",
type:"get"
})
.then((res)=>{
console.log(res);
})
.catch((err)=>{
console.log(err)
})

如果then和catch中的回调函数不是箭头函数,可以通过.bind(this)解决函数内部访问this实例的问题

      this.$http({
url:"https://api.api68.com/klsf/getLotteryInfo.do?issue=&lotCode=10009",
type:"get"
})
.then(function(res){
console.log(res);
console.log(this.msg);
}.bind(this))
.catch(function(err){
console.log(err)
}.bind(this))
}

最新文章

  1. ZOJ 2974 矩阵快速幂
  2. 在使用EFCodeFirst中出现类型“System.Data.Objects.ObjectContext”在未被引用的程序集中定义的解决方案
  3. ELK-Python(二)
  4. Java源码初学_ArrayList
  5. call的其他应用
  6. 导出Unity场景为配置文件
  7. VBS 操作注册表 十六进制
  8. C语言指针的初始化和赋值
  9. python网络编程基础(一)
  10. 数据分析三剑客之Matplotlib
  11. C#中生成GUID的四种格式
  12. Android文字转语音引擎(TTS)使用
  13. 【Checkio Exercise】Three Point Circle
  14. day0-功能自动化的前提
  15. Python从菜鸟到高手(5):数字
  16. ASP.NET MVC 4 (七) 模板帮助函数
  17. [Android] 图片裁剪总结——调用系统裁剪
  18. hdu 5385 The path
  19. nginx搭建负载均衡
  20. python中hashlib md5

热门文章

  1. 在使用Hanlp配置自定义词典时遇到的问题
  2. c++11多线程记录1 -- std::thread
  3. FORMAT 的用法
  4. PB 获取或操作数据窗口语句的方法
  5. Golang ---json解析
  6. 西门子S7-300 设置IP、子网掩码
  7. golang中生成读取二维码(skip2/go-qrcode和boombuler/barcode,tuotoo/qrcode)
  8. aria2 cmd set chmod, and others..
  9. k8s--complete-demo.yaml
  10. Gson含抽象类的反序列化