forked from wudengyao/admin_vue3_vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<div class="flex"> | ||
<div> | ||
<p style="margin-bottom: 20px">拖动图片到下面的灰色框</p> | ||
<img src="/favicon.ico" alt="Drop me"> | ||
|
||
<div ref="dropZoneRef" style="background:gainsboro;height: 400px;width: 400px;margin-top: 20px"> | ||
<div v-for="(file, index) in filesData" :key="index" style="padding: 20px"> | ||
<p>文件名: {{ file.name }}</p> | ||
<p>文件大小: {{ file.size }}</p> | ||
<p>文件类型: {{ file.type }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "useDropZone" | ||
} | ||
</script> | ||
<script setup> | ||
import { ref } from 'vue' | ||
import { useDropZone } from '@vueuse/core' | ||
const filesData = ref([]) | ||
function onDrop(files) { | ||
filesData.value = [] | ||
if (files) { | ||
filesData.value = files.map(file => ({ | ||
name: file.name, | ||
size: file.size, | ||
type: file.type, | ||
lastModified: file.lastModified, | ||
})) | ||
} | ||
} | ||
const dropZoneRef = ref(null) | ||
const { isOverDropZone } = useDropZone(dropZoneRef, onDrop) | ||
</script> | ||
|
||
<style scoped> | ||
</style> |