mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* 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>
40 lines
886 B
Vue
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>
|