tiny-vue_version0/examples/sites/demos/pc/app/pop-upload/prevent-delete-file-composi...

20 lines
574 B
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<tiny-pop-upload :action="action" :before-remove="handleRemove"></tiny-pop-upload>
</template>
<script setup lang="jsx">
import { ref } from 'vue'
import { PopUpload as TinyPopUpload, Modal } from '@opentiny/vue'
const action = ref('http://localhost:3000/api/upload')
function handleRemove(file) {
// return false 支持同步返回 也支持 Promise异步返回
return new Promise((resolve, reject) => {
Modal.confirm(`确定移除 ${file.name}`).then((res) => {
res === 'confirm' ? resolve() : reject(new Error())
})
})
}
</script>