Skip to content

Commit 6364c47

Browse files
committed
add fileStatusText function doc
1 parent 1c5ce08 commit 6364c47

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,27 @@ Root component.
164164
```
165165
An object map for file status text.
166166

167+
After 0.6.0, `fileStatusText` can be a function with params `(status, response = null)`, you can control the status text more flexible:
168+
169+
```js
170+
fileStatusText(status, response) {
171+
const statusTextMap = {
172+
uploading: 'uploading',
173+
paused: 'paused',
174+
waiting: 'waiting'
175+
}
176+
if (status === 'success' || status === 'error') {
177+
// only use response when status is success or error
178+
179+
// eg:
180+
// return response data ?
181+
return response.data
182+
} else {
183+
return statusTextMap[status]
184+
}
185+
}
186+
```
187+
167188
#### Events
168189

169190
See [simple-uploader.js uploader/events](https://github.com/simple-uploader/Uploader#events)

README_zh-CN.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,27 @@ new Vue({
168168
```
169169
用于转换文件上传状态文本映射对象。
170170

171+
0.6.0 版本之后,`fileStatusText` 可以设置为一个函数,参数为 `(status, response = null)`, 第一个 status 为状态,第二个为响应内容,默认 null,示例:
172+
173+
```js
174+
fileStatusText(status, response) {
175+
const statusTextMap = {
176+
uploading: 'uploading',
177+
paused: 'paused',
178+
waiting: 'waiting'
179+
}
180+
if (status === 'success' || status === 'error') {
181+
// 只有status为success或者error的时候可以使用 response
182+
183+
// eg:
184+
// return response data ?
185+
return response.data
186+
} else {
187+
return statusTextMap[status]
188+
}
189+
}
190+
```
191+
171192
#### 事件
172193

173194
参见 [simple-uploader.js uploader 事件](https://github.com/simple-uploader/Uploader/blob/develop/README_zh-CN.md#事件)

0 commit comments

Comments
 (0)