mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-14 18:11:48 +08:00

* perf: change to import-x * feat: add rules * chore: fix rule * chore: fix * chore: fix * chore: fix * style: `pnpm lint:fix` * Revert "style: `pnpm lint:fix`" This reverts commit db0116a288299c507e3cfc4d7a22e2207265d920. * Revert "chore: fix" This reverts commit 69c82a90c01525e38180be4c21e8ef5602512318. * chore: fix * style: `pnpm lint:fix` * fix: lint * chore: `pnpm format`
43 lines
1.0 KiB
Vue
43 lines
1.0 KiB
Vue
<template>
|
|
<el-upload
|
|
ref="upload"
|
|
class="upload-demo"
|
|
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
|
|
:limit="1"
|
|
:on-exceed="handleExceed"
|
|
:auto-upload="false"
|
|
>
|
|
<template #trigger>
|
|
<el-button type="primary">select file</el-button>
|
|
</template>
|
|
<el-button class="ml-3" type="success" @click="submitUpload">
|
|
upload to server
|
|
</el-button>
|
|
<template #tip>
|
|
<div class="el-upload__tip text-red">
|
|
limit 1 file, new file will cover the old file
|
|
</div>
|
|
</template>
|
|
</el-upload>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
import { genFileId } from 'element-plus'
|
|
|
|
import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus'
|
|
|
|
const upload = ref<UploadInstance>()
|
|
|
|
const handleExceed: UploadProps['onExceed'] = (files) => {
|
|
upload.value!.clearFiles()
|
|
const file = files[0] as UploadRawFile
|
|
file.uid = genFileId()
|
|
upload.value!.handleStart(file)
|
|
}
|
|
|
|
const submitUpload = () => {
|
|
upload.value!.submit()
|
|
}
|
|
</script>
|