ImagePreview.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /** 图片预览 */
  2. <template>
  3. <Modal
  4. ref="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. var Common = require('../../common/Common.js')
  22. var Modal = require('../../modal/src/Modal.vue').default
  23. export default {
  24. name: 'ImagePreview',
  25. components: {
  26. Modal,
  27. },
  28. props: {
  29. 'className':{
  30. type: String,
  31. },
  32. 'imageName':{
  33. type: String,
  34. },
  35. },
  36. data: function () {
  37. return {
  38. 'src': null,
  39. }
  40. },
  41. methods: {
  42. /**
  43. * 预览图片
  44. */
  45. preview: function (className, imageName) {
  46. if (imageName != null && imageName != '') {
  47. this.$refs.modal.show = true
  48. this.src = Common.getImageSrc(className, imageName)
  49. }
  50. },
  51. /**
  52. * 预览图片
  53. */
  54. previewImage: function (imageName) {
  55. this.$refs.modal.show = true
  56. this.src = imageName
  57. },
  58. },
  59. }
  60. </script>
  61. <style scoped>
  62. .modal-img-box {
  63. width: 100%;
  64. text-align: center;
  65. overflow: auto;
  66. }
  67. .m-img {
  68. width: 60%;
  69. }
  70. </style>