ImageViewer.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 '@/components/UploadImages/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. margin: auto;
  35. }
  36. .image-viewer__image {
  37. display: block;
  38. width: 120px;
  39. height: 90px;
  40. border-radius: 5px;
  41. }
  42. .image-viewer__text {
  43. position: absolute;
  44. bottom: 0px;
  45. right: 0px;
  46. background-color: rgba(0, 0, 0, 0.6);
  47. padding: 3px;
  48. color: rgba(255, 255, 255, 0.7);
  49. font-size: 14px;
  50. border-top-left-radius: 5px;
  51. border-bottom-right-radius: 5px;
  52. pointer-events: none;
  53. }
  54. </style>