diff --git a/packages/varlet-ui/src/uploader/Uploader.vue b/packages/varlet-ui/src/uploader/Uploader.vue index 3eeb75bf2c5..312a9ec1cfd 100644 --- a/packages/varlet-ui/src/uploader/Uploader.vue +++ b/packages/varlet-ui/src/uploader/Uploader.vue @@ -29,12 +29,12 @@ " v-if="!maxlength || modelValue.length < maxlength" v-ripple="{ disabled: disabled || formDisabled || readonly || formReadonly || !ripple || $slots.default }" - @click="triggerAction" + @click="chooseFile" > { - input.value!.click() - } - const preview = (varFile: VarFile) => { const { disabled, readonly, previewed } = props @@ -298,6 +294,18 @@ export default defineComponent({ // expose const getLoading = () => props.modelValue.filter((varFile) => varFile.state === 'loading') + // expose + const chooseFile = () => { + input.value!.click() + } + + // expose + const closePreview = () => { + currentPreview.value = null + showPreview.value = false + ImagePreview.close() + } + const varFileUtils: VarFileUtils = { getSuccess, getError, @@ -354,7 +362,6 @@ export default defineComponent({ formDisabled: form?.disabled, formReadonly: form?.readonly, preview, - triggerAction, handleChange, handleRemove, getSuccess, @@ -363,6 +370,8 @@ export default defineComponent({ validate, resetValidation, reset, + chooseFile, + closePreview, } }, }) diff --git a/packages/varlet-ui/src/uploader/__tests__/__snapshots__/index.spec.js.snap b/packages/varlet-ui/src/uploader/__tests__/__snapshots__/index.spec.js.snap index 7941ac72db8..26f151c8519 100644 --- a/packages/varlet-ui/src/uploader/__tests__/__snapshots__/index.spec.js.snap +++ b/packages/varlet-ui/src/uploader/__tests__/__snapshots__/index.spec.js.snap @@ -3,7 +3,7 @@ exports[`test uploader disabled 1`] = ` "