可能是由于Angular中的请求头和请求体设置不正确导致无法进行删除请求。以下是可能的解决方案:
const options = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }), body: { "id": 1 } };
this.http.delete(url, options).subscribe(response => { console.log(response); });
import { HttpClientModule } from '@angular/common/http';
@NgModule({ ... imports: [ ... HttpClientModule ], ... })
如果以上两点都没有解决问题,可以尝试使用Angular的HTTP拦截器来检查请求头和请求体,以确保它们设置正确。