angular 中 httpclient delete 请求,不接受 body,只需将其放在 options 对象中即可
在 angular6.x,angular7.x,angular8.x 及以上版本中修改如下:
const options = {
headers: new HttpHeaders({'Content-Type': 'application/json',}),
body:anyObject
};
this.httpClient
.delete('http://localhost:8080/something', options)
.subscribe((s) => {console.log(s);
});
在 Angular 2.x, 4.x and 5.x 中, 修改如下:
http.delete('/api/something', new RequestOptions({
headers: headers,
body: anyObject
}))
这样 delete 请求就可以携带 body