当前位置:网站首页>FormData的使用
FormData的使用
2022-07-26 23:18:00 【kilito_01】
export default {
toFormData(formModel) {
var formData = new FormData()
for (var name in formModel) {
var value = formModel[name]
this.setNameValue({
prefix: name, value, formData })
}
return formData
},
setNameValue({
prefix, value, formData }) {
if (value === undefined || value == null) {
return
}
if (typeof value === 'object') {
if (value instanceof FileList) {
var fileList = value
for (let i = 0; i < fileList.length; i++) {
formData.append(prefix, fileList[i])
}
} else if (value instanceof Array) {
if (value.length === 0) {
return
}
for (let i = 0; i < value.length; i++) {
this.setNameValue({
prefix: prefix + '[' + i + ']', value: value[i], formData })
}
} else {
for (var key in value) {
this.setNameValue({
prefix: prefix + '.' + key, value: value[key], formData })
}
}
} else {
formData.append(prefix, value)
}
}
}
边栏推荐
- [brother Yang takes you to play with the linear table (4) - chain queue]
- 30岁被裁,我想明白的几件事....
- Redis五种基本数据结构
- Hcip day 6 OSPF static experiment
- How many holes have you stepped on in BigDecimal?
- 东北证券股票网上开户,手机上开户安全吗
- Three handshakes and four disconnects of TCP
- TCP three handshakes and four disconnects
- 创业3年,现在鹅厂,年收入百万+,作为软件测试前辈的一些建议....
- uni-app上自定义微信小程序的tabbar
猜你喜欢

HCIP-第五天-OSPF扩展配置实验

聊聊自动化测试的度量指标

Record the nth SQL exception

I was fired at the age of 30. I want to understand a few things

The pointer is really profound!!!
![[brother Yang takes you to play with the linear table (4) - chain queue]](/img/b6/ea76e060be73bc14f2166144e7b5e7.png)
[brother Yang takes you to play with the linear table (4) - chain queue]
NPM reports an error, error: eperm: operation not permitted, MKDIR

OSPF routing information protocol topology experiment

uni-app 微信小程序搜索关键字标红显示

JMeter下载安装
随机推荐
After working in Tencent testing post for 5 years, I was ruthlessly dismissed in July, trying to wake up my brother who was still paddling
静态路由基本配置 实现全网可达
How many holes have you stepped on in BigDecimal?
Hcip first day
消息队列学习 -- 概念
[draw sherpinski triangle in C language]
N methods of SQL optimization
Today, let's talk about escape characters [cute new version]
小姐姐笔记:我是如何学习简单源码拓展视野的
测试工作十年,想对还在迷茫的朋友说:一点要做好个人规划...
创业3年,现在鹅厂,年收入百万+,作为软件测试前辈的一些建议....
Area optimization of digital chips: detailed explanation of question 1 in the digital direction of the third "Huawei Cup" graduate innovation core competition
【你了解Cache吗——全面理解高速缓冲存储器】
Constant knowledge explanation of C language
Static routing experiment configuration
[Fibonacci sequence and spiral are based on C language]
【Code】剑指offer 04二维数组中的查找
Encyclopedia of websites commonly used by people who know current affairs
After ten years of testing, I want to say to my friends who are still confused: one thing is to do a good job in personal planning
oSPF基础实验配置