个人博客地址:https://congz666.gitee.io/
post,put可以正常传参,但是delete请求无法传参
查阅一下axios各方法需要的参数
get<T = any>(url: string, config?: AxiosRequestConfig): AxiosPromise<T>;
delete(url: string, config?: AxiosRequestConfig): AxiosPromise;
head(url: string, config?: AxiosRequestConfig): AxiosPromise;
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
可以发现delete请求比post,put请求少了一个data的参数
所以我们需要通过config里的data进行传参
所以用delete传参数时应该这么写(假设传id):
axios.delete(’/api’,{data:{id:1}})