我用的是“反应”、“打字记录”和“Axios”。我声明一个类由如下的静态函数填充:
import axios from "axios"
export default class Users {
static checkinByPassword(username: string, password: string){
const params = {username, password}
return axios.post(`/${this._key}/checkinbypassword`, params)
}
static delete(id: string){
const params = {id: id}
return axios.delete(`/${this._key}`, params)
}
}第一个函数(checkinByPassword)工作得很好。第二个函数使ESLint ( ESLint用于VSCode编辑器)抛出一个错误:
Type '{ id: string; }' has no properties in common with type 'AxiosRequestConfig'.

AxiosRequestConfig是什么?如何使我的params对象与其兼容?先谢谢你
发布于 2020-03-02 07:04:30
axios.delete有两个参数,第一个是url路径,第二个是配置。
您需要包装您的params对象,另一个具有data属性的对象。
例如,:
const config = {
data: {
id: "your id"
}
}
axios.delete(url, config)...或
const params = {id: id};
axios.delete(url, {
data: params
})...https://stackoverflow.com/questions/60482505
复制相似问题