ImageViewer.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div class="image-viewer">
  3. <div v-if="images && images.length">
  4. <el-image
  5. fit="cover"
  6. :src="images[0]"
  7. :preview-src-list="images"
  8. class="image-viewer__image"
  9. :preview-teleported="true"
  10. />
  11. <div class="image-viewer__text">共{{ images.length }}张</div>
  12. </div>
  13. <div v-else> - </div>
  14. </div>
  15. </template>
  16. <script setup lang="ts">
  17. import { computed } from 'vue';
  18. import { unformatImage } from '../utils';
  19. const props = defineProps<{
  20. fileList: string;
  21. }>();
  22. const images = computed(() => {
  23. return unformatImage(props.fileList);
  24. });
  25. </script>
  26. <style scoped>
  27. .image-viewer {
  28. width: 120px;
  29. height: 90px;
  30. position: relative;
  31. display: flex;
  32. justify-content: center;
  33. align-items: center;
  34. }
  35. .image-viewer__image {
  36. width: 120px;
  37. height: 90px;
  38. border-radius: 5px;
  39. }
  40. .image-viewer__text {
  41. position: absolute;
  42. bottom: 0px;
  43. right: 0px;
  44. background-color: rgba(0, 0, 0, 0.6);
  45. padding: 3px;
  46. color: rgba(255, 255, 255, 0.7);
  47. font-size: 14px;
  48. border-top-left-radius: 5px;
  49. border-bottom-right-radius: 5px;
  50. pointer-events: none;
  51. }
  52. </style>