2021-09-17 00:18:50 +08:00
|
|
|
<template>
|
|
|
|
<el-upload
|
2022-06-17 15:01:30 +08:00
|
|
|
v-model:file-list="fileList"
|
|
|
|
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
|
2021-09-17 00:18:50 +08:00
|
|
|
list-type="picture-card"
|
|
|
|
:on-preview="handlePictureCardPreview"
|
|
|
|
:on-remove="handleRemove"
|
|
|
|
>
|
2022-03-05 23:09:31 +08:00
|
|
|
<el-icon><Plus /></el-icon>
|
2021-09-17 00:18:50 +08:00
|
|
|
</el-upload>
|
2022-03-23 18:50:36 +08:00
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
<el-dialog v-model="dialogVisible">
|
2022-03-23 18:50:36 +08:00
|
|
|
<img w-full :src="dialogImageUrl" alt="Preview Image" />
|
2021-09-17 00:18:50 +08:00
|
|
|
</el-dialog>
|
|
|
|
</template>
|
2022-03-10 23:52:13 +08:00
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { ref } from 'vue'
|
2021-12-04 11:20:06 +08:00
|
|
|
import { Plus } from '@element-plus/icons-vue'
|
2022-03-10 23:52:13 +08:00
|
|
|
|
2022-03-23 18:50:36 +08:00
|
|
|
import type { UploadProps, UploadUserFile } from 'element-plus'
|
2022-03-10 23:52:13 +08:00
|
|
|
|
|
|
|
const fileList = ref<UploadUserFile[]>([
|
|
|
|
{
|
|
|
|
name: 'food.jpeg',
|
|
|
|
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
|
|
|
},
|
|
|
|
{
|
2022-05-05 16:56:49 +08:00
|
|
|
name: 'plant-1.png',
|
|
|
|
url: '/images/plant-1.png',
|
2022-03-10 23:52:13 +08:00
|
|
|
},
|
2022-03-12 16:57:48 +08:00
|
|
|
{
|
|
|
|
name: 'food.jpeg',
|
|
|
|
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
|
|
|
},
|
|
|
|
{
|
2022-05-05 16:56:49 +08:00
|
|
|
name: 'plant-2.png',
|
|
|
|
url: '/images/plant-2.png',
|
2022-03-12 16:57:48 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food.jpeg',
|
|
|
|
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
|
|
|
},
|
|
|
|
{
|
2022-05-05 16:56:49 +08:00
|
|
|
name: 'figure-1.png',
|
|
|
|
url: '/images/figure-1.png',
|
2022-03-12 16:57:48 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food.jpeg',
|
|
|
|
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
|
|
|
},
|
|
|
|
{
|
2022-05-05 16:56:49 +08:00
|
|
|
name: 'figure-2.png',
|
|
|
|
url: '/images/figure-2.png',
|
2022-03-12 16:57:48 +08:00
|
|
|
},
|
2022-03-10 23:52:13 +08:00
|
|
|
])
|
2021-12-21 15:51:33 +08:00
|
|
|
|
|
|
|
const dialogImageUrl = ref('')
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
2022-03-23 18:50:36 +08:00
|
|
|
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
|
|
|
console.log(uploadFile, uploadFiles)
|
2021-12-21 15:51:33 +08:00
|
|
|
}
|
2022-03-23 18:50:36 +08:00
|
|
|
|
|
|
|
const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
|
|
|
|
dialogImageUrl.value = uploadFile.url!
|
2021-12-21 15:51:33 +08:00
|
|
|
dialogVisible.value = true
|
2021-09-17 00:18:50 +08:00
|
|
|
}
|
|
|
|
</script>
|