废话不多说,只讲干货
axios的封装请移步到  https://www.cnblogs.com/tlfe/p/11911915.html

挂载在React原型上的时候是这么写的:

在index.js文件中 引入axios文件

import axios from './api/api'
React.Component.prototype.$axios = axios

使用

//post请求
this.$axios.post('url',{key:value}).then(res =>{
   cons.log(res,'后端返回数据') 
})
//get请求
this.$axios.get('url?key=value').then(res =>{
   cons.log(res,'后端返回数据') 
})

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2021-06-16
  • 2021-09-10
猜你喜欢
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案