ImagePreview.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /** 图片预览 */
  2. <template>
  3. <Modal
  4. v-model:show="modal"
  5. :large="true"
  6. >
  7. <div class="modal-img-box">
  8. <img
  9. :src="src"
  10. class="m-img"
  11. />
  12. </div>
  13. <template #header>
  14. <slot>
  15. {{ $t('lang.imagePreview.imagePreview') }}
  16. </slot>
  17. </template>
  18. </Modal>
  19. </template>
  20. <script>
  21. import Common from '../../common/Common.js';
  22. import Modal from '../../modal/src/Modal.vue';
  23. export default {
  24. name: 'ImagePreview',
  25. components: {
  26. Modal,
  27. },
  28. props: {
  29. 'className':{
  30. type: String,
  31. default: null,
  32. },
  33. 'imageName':{
  34. type: String,
  35. default: null,
  36. },
  37. },
  38. data: function () {
  39. return {
  40. 'src': null,
  41. modal: false,
  42. };
  43. },
  44. methods: {
  45. /**
  46. * 预览图片
  47. */
  48. preview: function (className, imageName) {
  49. if (imageName != null && imageName != '') {
  50. this.modal = true;
  51. this.src = Common.getImageSrc(className, imageName);
  52. }
  53. },
  54. /**
  55. * 预览图片
  56. */
  57. previewImage: function (imageName) {
  58. this.modal = true;
  59. this.src = imageName;
  60. },
  61. },
  62. };
  63. </script>
  64. <style scoped>
  65. .modal-img-box {
  66. width: 100%;
  67. text-align: center;
  68. overflow: auto;
  69. }
  70. .m-img {
  71. width: 60%;
  72. }
  73. </style>