Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
upload-imgs: 实现图片上传成功、失败的钩子函数
  • Loading branch information
zhangxiaoshang committed Dec 9, 2019
commit dd660351d6abeaf749eebd7c859b279d213f508c
18 changes: 17 additions & 1 deletion src/components/base/upload-imgs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,16 @@ export default {
type: Boolean,
default: false,
},
/** 上传成功后的钩子 */
onSuccess: {
type: Function,
default: () => {},
},
/** 上传失败后的钩子 */
onError: {
type: Function,
default: () => {},
},
},
computed: {
/** 每项容器样式 */
Expand Down Expand Up @@ -621,8 +631,10 @@ export default {
this.originUpload(item, data => {
reduceResult(item, data)
if (!data) {
this.onError(item)
resolve(false)
} else {
this.onSuccess(item)
resolve(item)
}
})
Expand Down Expand Up @@ -1013,7 +1025,11 @@ export default {
// 检测是否是动图
let isAnimated = null
if (animatedCheck) {
isAnimated = await checkIsAnimated({ file, fileType, fileUrl: localSrc })
isAnimated = await checkIsAnimated({
file,
fileType,
fileUrl: localSrc,
})
}
return new Promise((resolve, reject) => {
let image = new Image()
Expand Down