axios的get请求和post请求的写法
get请求
-
一般的get请求写法 (在url上进行拼接参数)
this.$axios.get('http://localhost:8080/book/delBook?bookId=' + bookId).then(res=>{ console.log(res); }).catch(err=>{ console.log(err); })
-
需要传递对象参数的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内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复