chenhj
4 天以前 2fc58fbb10745abd97168b8da21d4142e11d7f2e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<template>
  <el-dialog
      v-model="visible"
      title="图片预览"
      width="800px"
      destroy-on-close
      align-center
  >
    <el-carousel
        v-if="images.length"
        height="450px"
        indicator-position="outside"
        arrow="always"
    >
      <el-carousel-item
          v-for="(img, index) in images"
          :key="index"
      >
        <el-image
            :src="img"
            fit="contain"
            style="width: 100%; height: 100%"
            :preview-src-list="images"
            :initial-index="index"
            preview-teleported
        />
      </el-carousel-item>
    </el-carousel>
 
    <div v-else class="empty">
      暂无图片
    </div>
  </el-dialog>
</template>
 
<script setup>
import { computed } from 'vue'
 
const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false
  },
  images: {
    type: Array,
    default: () => []
  }
})
 
const emit = defineEmits(['update:modelValue'])
 
const visible = computed({
  get: () => props.modelValue,
  set: val => emit('update:modelValue', val)
})
</script>
 
<style scoped>
.empty {
  text-align: center;
  color: #999;
  padding: 80px 0;
}
</style>