当前位置:网站首页>js对象转FormData对象(一般用于上传)
js对象转FormData对象(一般用于上传)
2022-08-10 10:19:00 【天高任鸟飞dyz】
export function getFormData(object) {
const formData = new FormData()
Object.keys(object).forEach(key => {
const value = object[key]
if (Array.isArray(value)) {
value.forEach((subValue, i) =>
formData.append(key + `[${i}]`, subValue)
)
} else {
formData.append(key, object[key])
}
})
return formData
}
边栏推荐
猜你喜欢
"Data Strategy" Results-Driven Enterprise Data Strategy: Organization and Governance
「数据战略」结果驱动的企业数据策略:组织和治理
MongoDB数据库笔记
「数据架构」数据模型,数据字典,数据库模式 和ERD的比较
Redis(三)——配置文件详解、发布和订阅、新数据类型
CentOS和Ubantu的Mysql主从配置
Dalian University of Technology & Pengcheng & UAE propose a mixed-scale triple network ZoomNet for camouflaged target detection, with SOTA performance!
Redis(六)——Redis6的事务和锁机制(未完成,待补)
Redis6(一)——NoSQL数据库简介与Redis的安装
chart.js horizontal column chart plugin
随机推荐
2022.8.7-----leetcode.636
Property animation QPropertyAnimation
首次入选OSDI顶会!腾讯提出超大规模推荐系统的模型低延时更新方案
「第二部:容器和微服务架构」(1) 基于容器应用架构设计原则
"Data Strategy" Results-Driven Enterprise Data Strategy: Organization and Governance
[C language] Header file #include
, conio is Console Input/Output (console input and output) Tencent releases the second-generation version of the quadruped robot Max, which completes jumps and somersaults on the plum blossom pile
LCD DRM驱动框架分析二
俄罗斯宣布临时禁止进口摩尔多瓦植物产品
VBA: 采用Combox控件实现二级下拉菜单功能
ES复杂操作搜索
"Chief Engineer" Principal (Principal) engineer's way of training
Redis (six) - transaction and lock mechanism of Redis6 (unfinished, to be supplemented)
PPT | 「课件」企业中高层人员安全管理培训(118页)
中国驻越南使馆提醒在越北部、中部地区中国公民做好台风“木兰”安全防范
「业务架构」TOGAF建模:业务功能分解图
Thrift -- 跨语言RPC 框架
Automated Testing and Selenium
C语言空白符、空格符 与转义字符题点总结
Redis6(一)——NoSQL数据库简介与Redis的安装