You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/products/tdesign-mobile-vue/src/upload/upload.en-US.md
+76Lines changed: 76 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,3 +73,79 @@ type | String | - | \- | N
73
73
uploadTime | String | - | upload time | N
74
74
url | String | - | \- | N
75
75
`PlainObject` | \- | - | `PlainObject` is not an attribute of UploadFile,it means you can add and attributes to UploadFile, `type PlainObject = {[key: string]: any}`' | N
76
+
77
+
## API
78
+
79
+
80
+
### Upload Props
81
+
82
+
name | type | default | description | required
83
+
-- | -- | -- | -- | --
84
+
accept | String | - | File types that can be accepted. [W3C](https://www.w3schools.com/tags/att_input_accept.asp),[MDN](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input/file) | N
85
+
action | String | - | Uploading URL | N
86
+
addBtn | Boolean | true | \- | N
87
+
addContent | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
88
+
allowUploadDuplicateFile | Boolean | false | allow to upload duplicate name files | N
89
+
autoUpload | Boolean | true | post upload request automatically after files being selected | N
90
+
beforeUpload | Function | - | stop one of files to upload。Typescript:`(file: UploadFile) => boolean \| Promise<boolean>` | N
91
+
capture | String | - | \- | N
92
+
data | Object | - | extra request data of uploading. `formatRequest` can redefine all request data。Typescript:`Record<string, any> \| ((files: UploadFile[]) => Record<string, any>)` | N
93
+
disabled | Boolean | undefined | make upload to be disabled | N
94
+
draggable | Boolean | false | Whether to enable drag-and-drop sorting | N
95
+
files | Array | [] | `v-model:files` is supported。Typescript:`Array<T>` | N
96
+
defaultFiles | Array | [] | uncontrolled property。Typescript:`Array<T>` | N
97
+
format | Function | - | to redefine `UploadFile` data structure。Typescript:`(file: File) => UploadFile` | N
98
+
formatRequest | Function | - | redefine request data。Typescript:`(requestData: { [key: string]: any }) => { [key: string]: any }` | N
99
+
formatResponse | Function | - | redefine response data structure。Typescript:`(response: any, context: FormatResponseContext) => ResponseType``type ResponseType = { error?: string; url?: string } & Record<string, any>`` interface FormatResponseContext { file: UploadFile; currentFiles?: UploadFile[] }`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/upload/type.ts) | N
imageProps | Object | - | Typescript:`ImageProps`,[Image API Documents](./image?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/upload/type.ts) | N
102
+
max | Number | 0 | max count of files limit | N
103
+
method | String | POST | HTTP request method。options: POST/GET/PUT/OPTIONS/PATCH/post/get/put/options/patch | N
onRemove | Function | | Typescript:`(context: UploadRemoveContext) => void`<br/>trigger on file removed。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/upload/type.ts)。<br/>`interface UploadRemoveContext { index?: number; file?: UploadFile; e: MouseEvent }`<br/> | N
119
+
onSelectChange | Function | | Typescript:`(files: File[], context: UploadSelectChangeContext) => void`<br/>trigger after file choose and before upload。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/upload/type.ts)。<br/>`interface UploadSelectChangeContext { currentSelectedFiles: UploadFile[] }`<br/> | N
120
+
onSuccess | Function | | Typescript:`(context: SuccessContext) => void`<br/>trigger on all files uploaded successfully。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/upload/type.ts)。<br/>`interface SuccessContext { e?: ProgressEvent; file?: UploadFile; fileList?: UploadFile[]; currentFiles?: UploadFile[]; response?: any; results?: SuccessContext[]; XMLHttpRequest?: XMLHttpRequest }`<br/> | N
121
+
onValidate | Function | | Typescript:`(context: { type: UploadValidateType, files: UploadFile[] }) => void`<br/>trigger on length over limit, or trigger on file size over limit。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/upload/type.ts)。<br/>`type UploadValidateType = 'FILE_OVER_SIZE_LIMIT' \| 'FILES_OVER_LENGTH_LIMIT' \| 'FILTER_FILE_SAME_NAME' \| 'BEFORE_ALL_FILES_UPLOAD' \| 'CUSTOM_BEFORE_UPLOAD'`<br/> | N
validate | `(context: { type: UploadValidateType, files: UploadFile[] })` | trigger on length over limit, or trigger on file size over limit。[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/tree/develop/src/upload/type.ts)。<br/>`type UploadValidateType = 'FILE_OVER_SIZE_LIMIT' \| 'FILES_OVER_LENGTH_LIMIT' \| 'FILTER_FILE_SAME_NAME' \| 'BEFORE_ALL_FILES_UPLOAD' \| 'CUSTOM_BEFORE_UPLOAD'`<br/>
136
+
137
+
### UploadFile
138
+
139
+
name | type | default | description | required
140
+
-- | -- | -- | -- | --
141
+
lastModified | Number | - | \- | N
142
+
name | String | - | \- | N
143
+
percent | Number | - | \- | N
144
+
raw | Object | - | Typescript:`File` | N
145
+
response | Object | - | Typescript:`{ [key: string]: any }` | N
146
+
size | Number | - | \- | N
147
+
status | String | - | Typescript:` 'success' \| 'fail' \| 'progress' \| 'waiting'` | N
148
+
type | String | - | \- | N
149
+
uploadTime | String | - | upload time | N
150
+
url | String | - | \- | N
151
+
`PlainObject` | \- | - | `PlainObject` is not an attribute of UploadFile,it means you can add and attributes to UploadFile, `type PlainObject = {[key: string]: any}`' | N
0 commit comments