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"
})