Comments (2)
描述错误
axiosResponseData默认应该是any才对吧 在axios库中
export interface AxiosResponse<T = any, D = any> { data: T; status: number; statusText: string; headers: RawAxiosResponseHeaders | AxiosResponseHeaders; config: InternalAxiosRequestConfig<D>; request?: any; }https://github.com/axios/axios/blob/a989ccdc1a672171e9b45d3f02edc260109a607c/index.d.ts#L378
附加上下文
没有反应
使用过的包管理器
新项目管理
验证
很高兴能够收到你的反馈。
为什么没有使用 any?
因为 axios 的类型不够严格,所以我并没有完全参考它,该库的类型定义是比 axios 更为严格的,总的来说对 axios 的类型做了补强吧。
这里不使用 any 能够更好的提醒用户,在不知道后端会返回什么样的数据时做好类型判断。
如果你知道后端会返回什样的数据,定义好类型才是更好的选择,当然也可以传入 any 泛型,忽略报错,但不太建议这样做。
另外 taro,uni-app 也都对 data 做的严格的类型定义,严格的类型限制总得来说肯定是利大于弊的,不然太容易把 TypeScript
写成 AnyScript
。
from axios-miniprogram.
好的谢谢
from axios-miniprogram.
Related Issues (20)
- 请求url的端口号被替换为undefined HOT 4
- 小程序中无法使用,还是我接入方式不正确 HOT 2
- 是否支持 uni-app vue3 cli模式 HOT 1
- 请问支持快手小程序吗, 只需要get和post HOT 2
- 不能在axios的config中增加自定义字段 HOT 1
- 请问支持uniapp 打包成安卓app吗? HOT 1
- uni-app 即将不再内部支持!
- 自定义config headers丢失 HOT 6
- 不要去掉url的斜线 HOT 4
- 钉钉小程序中真机预览报无权跨域调用 HOT 3
- 当上下顺序发送请求后,配置中的数据相同 HOT 1
- post 无法使用formData入参 HOT 5
- 上传文件名为中文时后端怎么还原? HOT 10
- 能否支持最新的axios HOT 3
- 小程序导入 执行完npm 构建 一直提示这个,Error: module 'xxx/xxx/axios-miniprogram.js' is not defined, require args is 'axios-miniprogram' HOT 5
- 文件上传乱码与返回格式问题 HOT 2
- 请求拦截器中,修改header会导致全局变化 HOT 1
- 原生微信小程序 解决 module 'utils/axios-miniprogram.js' is not defined, require args is 'axios-miniprogram' HOT 1
- uniapp h5 打包以后无法请求
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axios-miniprogram.