Property 'xxx' does not exist on type 'AxiosResponse<any, any>' 的解决办法
问题描述
在vue3 + ts 项目中,使用axios库调接口时报了如下错误:
1  | Property 'code' does not exist on type 'AxiosResponse<any, any>'.ts(2339)  | 

或者遇到 Property 'xxx' does not exist on type 'AxiosResponse<any, any>'.ts(2339) 类型问题我们该如何解决呢?
解决方法
新建一个axios.d.ts文件,内容如下:
1  | // 定义接口返回数据类型,这里根据后端返回去定义  | 
加上之后的效果:

 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 唐志远!
 评论













