在ts中axios返回not exist on type 'AxiosResponse'
分类: 程序开发 12363 0
vue的axios请求返回值调取时报下面这错误
Property 'content' does not exist on type 'AxiosResponse<any>'.Vetur(2339)

解决方法是新增一个 axios.d.ts
文件,内容如下
import * as axios from 'axios'
declare module 'axios' {
interface AxiosInstance {
(config: AxiosRequestConfig): Promise<any>
}
}
就可以解决了
方案来自 https://github.com/axios/axios/issues/1510#issuecomment-529284409
共 0 条评论关于 “在ts中axios返回not exist on type 'AxiosResponse'”