-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHTMLFormElement.ts
37 lines (36 loc) · 1.29 KB
/
HTMLFormElement.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
interface HTMLFormElement extends Element {
/**
* 將表單數據轉換為 Map 對象
* @readonly
* @returns Map<string, any> | undefined
* - 若表單有效,返回包含所有表單欄位的 Map 對象:
* - key: 表單欄位的 name 屬性值
* - value: 表單欄位的值(可能是字串、檔案或其他類型)
* - 若表單無效或不是表單元素,返回 undefined
*
* @example
* const form = document.querySelector('form');
* const formData = form.$map;
* if (formData) {
* console.log(formData.get('username'));
* }
*/
readonly $map: Map<string, any> | undefined;
/**
* 將表單數據轉換為 JSON 對象
* @readonly
* @returns Record<string, any> | undefined
* - 若表單有效,返回包含所有表單欄位的普通 JavaScript 對象:
* - key: 表單欄位的 name 屬性值
* - value: 表單欄位的值(可能是字串、檔案或其他類型)
* - 若表單無效或不是表單元素,返回 undefined
*
* @example
* const form = document.querySelector('form');
* const formData = form.$json;
* if (formData) {
* console.log(formData.username);
* }
*/
readonly $json: Record<string, any> | undefined;
}