+
{slots.default()}
{Input}
@@ -329,7 +360,7 @@ export default defineComponent({
return (
,
lazyLoad: Boolean,
deletable: Boolean,
+ reupload: Boolean,
previewSize: [Number, String, Array] as PropType<
Numeric | [Numeric, Numeric]
>,
beforeDelete: Function as PropType,
},
- emits: ['delete', 'preview'],
+ emits: ['delete', 'preview', 'reupload'],
setup(props, { emit, slots }) {
const renderMask = () => {
@@ -71,6 +72,8 @@ export default defineComponent({
const onPreview = () => emit('preview');
+ const onReupload = () => emit('reupload');
+
const renderDeleteIcon = () => {
if (props.deletable && props.item.status !== 'uploading') {
const slot = slots['preview-delete'];
@@ -104,7 +107,7 @@ export default defineComponent({
};
const renderPreview = () => {
- const { item, lazyLoad, imageFit, previewSize } = props;
+ const { item, lazyLoad, imageFit, previewSize, reupload } = props;
if (isImageFile(item)) {
return (
@@ -116,7 +119,7 @@ export default defineComponent({
width={Array.isArray(previewSize) ? previewSize[0] : previewSize}
height={Array.isArray(previewSize) ? previewSize[1] : previewSize}
lazyLoad={lazyLoad}
- onClick={onPreview}
+ onClick={reupload ? onReupload : onPreview}
/>
);
}
diff --git a/packages/vant/src/uploader/demo/index.vue b/packages/vant/src/uploader/demo/index.vue
index f69fe2e9f..cf2c784a8 100644
--- a/packages/vant/src/uploader/demo/index.vue
+++ b/packages/vant/src/uploader/demo/index.vue
@@ -25,6 +25,7 @@ const t = useTranslate({
previewCover: '自定义预览样式',
deleteMessage: '删除前置处理',
customPreviewImage: '自定义单个图片预览',
+ reupload: '开启覆盖上传',
},
'en-US': {
status: 'Upload Status',
@@ -44,6 +45,7 @@ const t = useTranslate({
previewCover: 'Preview Cover',
deleteMessage: 'Before Delete',
customPreviewImage: 'Custom single preview image',
+ reupload: 'Open Reupload',
},
});
@@ -142,6 +144,8 @@ const onOversize = (file: UploaderFileListItem, detail: unknown) => {
console.log(file, detail);
showToast(t('overSizeTip'));
};
+
+const fileList6 = ref([{ url: cdnURL('leaf.jpeg') }]);
@@ -201,6 +205,10 @@ const onOversize = (file: UploaderFileListItem, detail: unknown) => {
+
+
+
+