Files
element-plus/docs/examples/upload/limit-cover.vue
Alan Wang 23712260f0 docs: [el-upload]add example of setting on-exceed to cover the old file (#4861)
* docs: [el-upload]add example of seting on-exceed to cover the old file

* Update packages/components/upload/src/useHandlers.ts

Co-authored-by: btea <2356281422@qq.com>

* Update docs/examples/upload/limit-cover.vue

Co-authored-by: btea <2356281422@qq.com>

Co-authored-by: btea <2356281422@qq.com>
2021-12-21 09:27:52 +08:00

40 lines
886 B
Vue

<template>
<el-upload
ref="upload"
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:limit="1"
:on-exceed="handleExceed"
:auto-upload="false"
>
<template #trigger>
<el-button size="small" type="primary">select file</el-button>
</template>
<el-button
style="margin-left: 10px"
size="small"
type="success"
@click="submitUpload"
>upload to server</el-button
>
<template #tip>
<div class="el-upload__tip" style="color: red">
limit 1 file, new file will cover the old file
</div>
</template>
</el-upload>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const upload = ref()
const handleExceed = (files) => {
upload.value.clearFiles()
upload.value.handleStart(files[0])
}
const submitUpload = () => {
upload.value.submit()
}
</script>