提交 11d04cca 编写于 作者: D dolymood

upload support action checkSuccess option

上级 dddedd2b
......@@ -31,7 +31,11 @@
action: '//jsonplaceholder.typicode.com/photos/',
action2: {
target: '//jsonplaceholder.typicode.com/photos/',
prop: 'base64Value'
prop: 'base64Value',
checkSuccess(res) {
// success
return true
}
},
isUploading: true
}
......
......@@ -13,7 +13,8 @@ export default function ajaxUpload(file, options, changeHandler) {
withCredentials,
timeout,
prop = 'file',
progressInterval = 100
progressInterval = 100,
checkSuccess = function () { return true }
} = options
file.progress = 0
......@@ -65,7 +66,9 @@ export default function ajaxUpload(file, options, changeHandler) {
} catch (e) {}
file.response = response
file.responseHeaders = xhr.getAllResponseHeaders()
setStatus(STATUS_SUCCESS)
const isSuccess = checkSuccess(response)
setStatus(isSuccess ? STATUS_SUCCESS : STATUS_ERROR)
}
xhr.onerror = function () {
setStatus(STATUS_ERROR)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册