mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-14 18:11:48 +08:00
docs: [upload] improve typings (#6764)
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
<el-button type="primary">Click to upload</el-button>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
jpg/png files with a size less than 500kb
|
||||
jpg/png files with a size less than 500KB.
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
@ -22,7 +22,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
import type { UploadUserFile, UploadFile } from 'element-plus'
|
||||
import type { UploadUserFile, UploadProps } from 'element-plus'
|
||||
|
||||
const fileList = ref<UploadUserFile[]>([
|
||||
{
|
||||
@ -35,21 +35,26 @@ const fileList = ref<UploadUserFile[]>([
|
||||
},
|
||||
])
|
||||
|
||||
const handleRemove = (file: UploadFile, fileList: UploadFile[]) => {
|
||||
console.log(file, fileList)
|
||||
const handleRemove: UploadProps['onRemove'] = (file, uploadFiles) => {
|
||||
console.log(file, uploadFiles)
|
||||
}
|
||||
const handlePreview = (file: UploadFile) => {
|
||||
console.log(file)
|
||||
|
||||
const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
|
||||
console.log(uploadFile)
|
||||
}
|
||||
const handleExceed = (files: File[], fileList: UploadFile[]) => {
|
||||
|
||||
const handleExceed: UploadProps['onExceed'] = (files, uploadFiles) => {
|
||||
ElMessage.warning(
|
||||
`The limit is 3, you selected ${files.length} files this time, add up to ${
|
||||
files.length + fileList.length
|
||||
files.length + uploadFiles.length
|
||||
} totally`
|
||||
)
|
||||
}
|
||||
const beforeRemove = (file: UploadFile, fileList: UploadFile[]) => {
|
||||
return ElMessageBox.confirm(`Cancel the transfert of ${file.name} ?`).then(
|
||||
|
||||
const beforeRemove: UploadProps['beforeRemove'] = (uploadFile, uploadFiles) => {
|
||||
return ElMessageBox.confirm(
|
||||
`Cancel the transfert of ${uploadFile.name} ?`
|
||||
).then(
|
||||
() => true,
|
||||
() => false
|
||||
)
|
||||
|
Reference in New Issue
Block a user