tiny-vue/examples/sites/demos/mobile/app/file-upload/prevent-delete-file.vue

48 lines
948 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-file-upload
ref="upload"
:action="action"
:file-list="fileList"
:auto-upload="false"
:before-remove="beforeRemove"
>
<template #trigger>
<icon-upload></icon-upload>
</template>
</tiny-file-upload>
</template>
<script lang="jsx">
import { FileUpload } from '@opentiny/vue'
import { iconUpload } from '@opentiny/vue-icon'
export default {
components: {
TinyFileUpload: FileUpload,
IconUpload: iconUpload()
},
data() {
return {
action: '',
fileList: [
{
name: 'test1',
url: `${import.meta.env.VITE_APP_BUILD_BASE_URL}static/images/ld.png`
}
]
}
},
methods: {
beforeRemove(file, fileList) {
return new Promise((resolve, reject) => {
if (window.confirm(`确定移除 ${file.name}`)) {
resolve()
} else {
reject(new Error())
}
})
}
}
}
</script>