Skip to content

Commit 23ad1b7

Browse files
committed
feat(Upload): 文件上传增加删除事件
1 parent a3d3369 commit 23ad1b7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

docs/src/pages/components/mobile/upload.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ app.use(DUpload)
104104
|exceed-count|文件个数超出限制|-|
105105
|success|文件上传成功回调|`value: Response`|
106106
|error|文件上传失败回调|`value: Response`|
107+
|remove|文件删除回调|`value: { index: number, item: UploadListItemType }`|
107108

108109
### TypeScript 类型
109110

packages/dl-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xuanmo/dl-ui",
3-
"version": "0.0.5-beta.42",
3+
"version": "0.0.5-beta.43",
44
"author": {
55
"name": "xuanmo",
66
"email": "me@xuanmo.xin"

packages/dl-ui/src/upload/upload.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ export default defineComponent({
4141
UploadList
4242
},
4343
props: UPLOAD_PROPS,
44-
emits: ['update:model-value', 'change', 'success', 'error', 'exceed-count', 'exceed-size'],
44+
emits: [
45+
'update:model-value',
46+
'change',
47+
'success',
48+
'error',
49+
'exceed-count',
50+
'exceed-size',
51+
'remove'
52+
],
4553
setup(props, { emit }) {
4654
const { emit: formEventEmit } = useFormEvent(props.model!)
4755
const wrapperClassName = bem()
@@ -168,7 +176,8 @@ export default defineComponent({
168176
169177
const handleDeleteItem = (index: number) => {
170178
const newValue = deepCopy(props.modelValue)
171-
newValue.splice(index, 1)
179+
const item = newValue.splice(index, 1)[0]
180+
emit('remove', { index, item })
172181
emit('update:model-value', newValue)
173182
}
174183

0 commit comments

Comments
 (0)