2021-09-17 00:18:50 +08:00
|
|
|
<template>
|
|
|
|
<el-upload
|
|
|
|
action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
|
list-type="picture-card"
|
|
|
|
:on-preview="handlePictureCardPreview"
|
|
|
|
:on-remove="handleRemove"
|
2022-03-10 23:52:13 +08:00
|
|
|
:file-list="fileList"
|
2021-09-17 00:18:50 +08:00
|
|
|
>
|
2022-03-05 23:09:31 +08:00
|
|
|
<el-icon><Plus /></el-icon>
|
2021-09-17 00:18:50 +08:00
|
|
|
</el-upload>
|
|
|
|
<el-dialog v-model="dialogVisible">
|
2022-03-10 23:52:13 +08:00
|
|
|
<img style="width: 100%" :src="dialogImageUrl" alt="" />
|
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
|
|
|
|
|
|
|
import type { UploadFile, UploadUserFile } from 'element-plus'
|
|
|
|
|
|
|
|
const fileList = ref<UploadUserFile[]>([
|
|
|
|
{
|
|
|
|
name: 'food.jpeg',
|
|
|
|
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food2.jpeg',
|
|
|
|
url: '/images/guide.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',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food2.jpeg',
|
|
|
|
url: '/images/guide.png',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food.jpeg',
|
|
|
|
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food2.jpeg',
|
|
|
|
url: '/images/guide.png',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food.jpeg',
|
|
|
|
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food2.jpeg',
|
|
|
|
url: '/images/guide.png',
|
|
|
|
},
|
2022-03-10 23:52:13 +08:00
|
|
|
])
|
2021-12-21 15:51:33 +08:00
|
|
|
|
|
|
|
const dialogImageUrl = ref('')
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
|
|
|
const handleRemove = (file: UploadFile, fileList: UploadFile[]) => {
|
|
|
|
console.log(file, fileList)
|
|
|
|
}
|
|
|
|
const handlePictureCardPreview = (file: UploadFile) => {
|
|
|
|
dialogImageUrl.value = file.url!
|
|
|
|
dialogVisible.value = true
|
2021-09-17 00:18:50 +08:00
|
|
|
}
|
|
|
|
</script>
|