FormDataEvent:FormDataEvent() 构造函数
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
FormDataEvent()
构造函数创建一个新的 FormDataEvent
对象。
语法
js
new FormDataEvent(type, formEventInit)
参数
type
-
包含事件名称的字符串。它区分大小写,且浏览器总是将其设置为
formdata
。 options
-
一个对象,该对象除了在
Event()
中定义的属性之外,还可以具有以下属性:formData
-
一个预填充
FormDataEvent
的FormData
对象,然后可以通过FormDataEvent.formData
属性访问该对象。
返回值
一个新的 FormDataEvent
对象。
示例
js
const fd = new FormData();
fd.append("test", "test");
const fdEv = new FormDataEvent("formdata", { formData: fd });
for (const value of fdEv.formData.values()) {
console.log(value);
}
规范
Specification |
---|
HTML # the-formdataevent-interface |
浏览器兼容性
BCD tables only load in the browser