ImagePreview.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <base-dialog
  3. v-model="visible"
  4. less
  5. title="试卷预览"
  6. :can-resize="'can-resize2'"
  7. :modal="false"
  8. class="preview-dialog"
  9. >
  10. <div class="preview-content" :class="{ 'is-big': isBig }">
  11. <img v-show="!!url" :src="url" alt="" />
  12. </div>
  13. </base-dialog>
  14. </template>
  15. <script setup lang="ts" name="ImagePreview">
  16. import BaseDialog from '../element/BaseDialog.vue'
  17. import useVModel from '@/hooks/useVModel'
  18. const props = defineProps<{
  19. modelValue: boolean
  20. url?: string
  21. isBig?: boolean
  22. }>()
  23. const visible = useVModel(props)
  24. </script>
  25. <style scoped lang="scss">
  26. .preview-dialog {
  27. margin-left: 70%;
  28. .preview-content {
  29. width: 100%;
  30. min-width: 250px;
  31. // max-width: 400px;
  32. text-align: center;
  33. min-height: 40vh;
  34. // max-height: 600px;
  35. // max-height: calc(50vh - 50px);
  36. overflow: auto;
  37. &.is-big {
  38. max-width: 50vw;
  39. height: calc(100vh - 50px);
  40. img {
  41. width: auto;
  42. height: 99%;
  43. }
  44. }
  45. img {
  46. // width: 100%;
  47. // height: 100%;
  48. height: calc(50vh - 50px);
  49. width: auto;
  50. object-fit: contain;
  51. }
  52. }
  53. }
  54. </style>