We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在前端项目中替换 axios 和 qs 模块,减少 73KB!
axios
qs
之前使用 qs 的原因是:
qs.stringify({ a: { b: 1 } })
qs.parse(location.search).token
然而,你可以使用更轻量的替代方案实现相同功能:
URLSearchParams
new URLSearchParams(location.search).get('token')
xior
import { encodeParams as stringify } from 'xior'; stringify({ a: { b: 1 } });
至于 axios,许多开发者使用它是因为它的便捷 API。然而,使用这个类似 axios 的 Fetch 封装,你可以将包体积从 35.6KB 减少到 6KB!
Xior.js
唯一的区别就是 把 axios 换成 xior!
import axios, { XiorError as AxiosError, isXiorError as isAxiosError, XiorRequestConfig as AxiosRequestConfig, XiorResponse as AxiosResponse, } from 'xior'; const instance = axios.create({ baseURL: '...', timeout: 20e3, });
所以,为什么你还在前端项目中使用 qs 和 axios?
如果有任何问题或遇到 bug,请留言或创建 Issue。
立即查看 👉 https://github.com/suhaotian/xior
原文翻译自:Replace axios and qs modules with this in frontend projects and reduce 73KB!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在前端项目中替换
axios
和qs
模块,减少 73KB!之前使用
qs
的原因是:然而,你可以使用更轻量的替代方案实现相同功能:
URLSearchParams
:xior
提供的轻量实现:至于
axios
,许多开发者使用它是因为它的便捷 API。然而,使用这个类似axios
的 Fetch 封装,你可以将包体积从 35.6KB 减少到 6KB!各模块的体积对比:
axios
模块大小:qs
模块大小:Xior.js
大小:而且 API 几乎与 Axios 相同:
唯一的区别就是 把
axios
换成xior
!所以,为什么你还在前端项目中使用
qs
和axios
?如果有任何问题或遇到 bug,请留言或创建 Issue。
立即查看 👉 https://github.com/suhaotian/xior
原文翻译自:Replace axios and qs modules with this in frontend projects and reduce 73KB!
The text was updated successfully, but these errors were encountered: