axios的使用过程

2021/5/25 10:26:29

本文主要是介绍axios的使用过程,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

与vue-resource使用过程一致

1.下载

npm install axios --save

2. 引入模块

import axios from 'axios'

3. 发送请求

axios.get(url).then(response => {

  // 成功了

  const result = response.data 

  const mostRepo = result.items[0]

  this.repoUrl = mostRepo.html_url

  this.repoName = mostRepo.name

}).catch(error => {

  alert('axios请求失败')

})

 



这篇关于axios的使用过程的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程