ImagePreview.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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" class="small-img" :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 lang="scss">
  26. .preview-dialog {
  27. display: flex;
  28. flex-direction: column;
  29. .el-dialog__body {
  30. flex: 1;
  31. padding: 2px !important;
  32. .preview-content {
  33. width: 100%;
  34. height: 100%;
  35. }
  36. }
  37. .el-dialog__footer {
  38. padding: 0 !important;
  39. }
  40. }
  41. </style>
  42. <style scoped lang="scss">
  43. .preview-dialog {
  44. // margin-left: 70%;
  45. .preview-content {
  46. width: 100%;
  47. // min-width: 250px;
  48. // max-width: 400px;
  49. text-align: center;
  50. // min-height: 40vh;
  51. // max-height: 600px;
  52. // max-height: calc(50vh - 50px);
  53. // height: 50vh;
  54. // width: 300px;
  55. overflow: auto;
  56. // &.is-big {
  57. // max-width: 50vw;
  58. // height: calc(100vh - 50px);
  59. // img {
  60. // width: auto;
  61. // height: 99%;
  62. // }
  63. // }
  64. img {
  65. width: 100%;
  66. // height: 100%;
  67. // height: calc(50vh - 50px);
  68. // width: auto;
  69. height: auto;
  70. object-fit: contain;
  71. }
  72. }
  73. }
  74. </style>