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
4.2.3
windows11 node20 antdv4.2.3
https://www.antdv.com/components/upload-cn#customrequest-%E6%80%8E%E4%B9%88%E4%BD%BF%E7%94%A8%EF%BC%9F
使用自定义上传customRequest并且调用onSuccess方法 传入字符串(比如雪花ID)
customRequest
async function customRequest(info: UploadRequestOption) { info.onSucess('12345678901234567890') }
不被转换为Number 实际应该为String
字符串被转换为Number类型 如果超过js安全数会丢失精度 源码位置:https://github.com/vueComponent/ant-design-vue/blob/main/components/upload/Upload.tsx#L198
const onSuccess = (response: any, file: FileType, xhr: any) => { try { if (typeof response === 'string') { response = JSON.parse(response); } } catch (e) { /* do nothing */ } ...省略 };
传入为string会走JSON.parse逻辑 会将String转为Number
JSON.parse
比如后端返回为雪花ID 超过js安全数会造成丢失精度问题
The text was updated successfully, but these errors were encountered:
业务层的数据精度应该由业务层自行处理
Sorry, something went wrong.
No branches or pull requests
Version
4.2.3
Environment
windows11 node20 antdv4.2.3
Reproduction link
https://www.antdv.com/components/upload-cn#customrequest-%E6%80%8E%E4%B9%88%E4%BD%BF%E7%94%A8%EF%BC%9F
Steps to reproduce
使用自定义上传
customRequest
并且调用onSuccess方法 传入字符串(比如雪花ID)What is expected?
不被转换为Number 实际应该为String
What is actually happening?
字符串被转换为Number类型 如果超过js安全数会丢失精度
源码位置:https://github.com/vueComponent/ant-design-vue/blob/main/components/upload/Upload.tsx#L198
传入为string会走
JSON.parse
逻辑 会将String转为Number比如后端返回为雪花ID 超过js安全数会造成丢失精度问题
The text was updated successfully, but these errors were encountered: