当前位置:   article > 正文

axios请求传递参数_axios get请求参数

axios get请求参数

axios请求传递参数

1、 get请求传参

axios.get('http://localhost:3000/axios?id=123').then(function(ret){
       console.log(ret.data)
     })
  • 1
  • 2
  • 3
axios.get('http://localhost:3000/axios/123').then(function(ret){
       console.log(ret.data)
     })
  • 1
  • 2
  • 3
axios.get('http://localhost:3000/axios', {
       params: {
         id: 789
       }
     }).then(function(ret){
       console.log(ret.data)
     })
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

2、 delete请求传参

axios.delete('http://localhost:3000/axios', {
       params: {
       id: 111
       }
     }).then(function(ret){
       console.log(ret.data)
     })
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

3、 post请求传参

axios.post('http://localhost:3000/axios', {
      uname: 'lisi',
      pwd: 123
     }).then(function(ret){
       console.log(ret.data)
     })
     var params = new URLSearchParams();
     params.append('uname', 'zhangsan');
     params.append('pwd', '111');
     axios.post('http://localhost:3000/axios', params).then(function(ret){
       console.log(ret.data)
     })
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

4、 put请求传参

 axios.put('http://localhost:3000/axios/123', {
      uname: 'lisi',
      pwd: 123
    }).then(function(ret){
      console.log(ret.data)
    })
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/426913
推荐阅读
相关标签
  

闽ICP备14008679号