-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
Version
4.2.3
Environment
windows11 node20 antdv4.2.3
Reproduction link
Steps to reproduce
使用自定义上传customRequest
并且调用onSuccess方法 传入字符串(比如雪花ID)
async function customRequest(info: UploadRequestOption) {
info.onSucess('12345678901234567890')
}
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
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
比如后端返回为雪花ID 超过js安全数会造成丢失精度问题
Metadata
Metadata
Assignees
Labels
No labels