ImageViewer.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. }
  32. .image-viewer__image {
  33. width: 120px;
  34. height: 90px;
  35. border-radius: 5px;
  36. }
  37. .image-viewer__text {
  38. position: absolute;
  39. bottom: 0px;
  40. right: 0px;
  41. background-color: rgba(0, 0, 0, 0.6);
  42. padding: 3px;
  43. color: rgba(255, 255, 255, 0.7);
  44. font-size: 14px;
  45. border-top-left-radius: 5px;
  46. border-bottom-right-radius: 5px;
  47. pointer-events: none;
  48. }
  49. </style>