1.post请求
axios.post("http://localhost:8089/add",form).then(res=>{ console.log(res) })
form:是一个Json对象 即 {key:value}
发送请求后的url形式:http://localhost:8089/add 数据会以请求体的形式发送给后端
例如:
2.get请求
2.1以查询字符串的形式传递
axios.get("后端接口",{params:form}).then(res=>{ })
form:是一个Json对象 即 {username:"张三"}
http://localhost:8089/user?username=张三
发送请求后的url形式:http://localhost:8089/user?username=张三
2.2以标准格式查询
http://localhost:8089/user/张三
axios.get("http://localhost:8089/user/张三").then(res=>{ })
3.put请求
axios.request.put("后端接口",form).then(res=>{ console.log(res) })
4.delete请求
axios.request.delete("后端接口",form).then(res=>{ console.log(res) })