我是靠谱客的博主 激昂帽子,这篇文章主要介绍【Axios】axios的get请求和post请求的写法,现在分享给大家,希望可以做个参考。

axios的get请求和post请求的写法

get请求

  1. 一般的get请求写法 (在url上进行拼接参数)

    this.$axios.get('http://localhost:8080/book/delBook?bookId=' + bookId).then(res=>{
    console.log(res);
    }).catch(err=>{
    console.log(err);
    })
    
  2. 需要传递对象参数的get请求写法

    this.$axios.get('http://localhost:8080/book/delBook',{
    params:{
    bookId:"bookId",
    bookName:"bookName"
    }
    })
    

    注意:params关键字不能省略

Post请求

this.$axios.post('http://localhost:8080/search',{
bookId:"bookId",
bookName:"bookName"
})

最后

以上就是激昂帽子最近收集整理的关于【Axios】axios的get请求和post请求的写法的全部内容,更多相关【Axios】axios内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(72)

评论列表共有 0 条评论

立即
投稿
返回
顶部