FullImage.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="full-image" v-if="show" :before-close="close" :modal="true">
  3. <div class="mask"></div>
  4. <div class="image-box">
  5. <img :src="url" />
  6. </div>
  7. <div class="close" @click="close"><i class="el-icon-close"></i></div>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. name: "fullImage",
  13. data() {
  14. return {
  15. show: false,
  16. url: ''
  17. }
  18. },
  19. methods: {
  20. open(url) {
  21. this.show = true;
  22. this.url = url;
  23. },
  24. close() {
  25. this.show = false;
  26. }
  27. }
  28. }
  29. </script>
  30. <style lang="scss" scoped>
  31. .full-image {
  32. position: fixed;
  33. width: 100%;
  34. height: 100%;
  35. left: 0;
  36. top: 0;
  37. bottom: 0;
  38. right: 0;
  39. .mask {
  40. position: fixed;
  41. width: 100%;
  42. height: 100%;
  43. background: black;
  44. opacity: 0.5;
  45. }
  46. .image-box {
  47. position: relative;
  48. width: 100%;
  49. height: 100%;
  50. img {
  51. position: absolute;
  52. left: 50%;
  53. top: 50%;
  54. transform: translate(-50%, -50%);
  55. max-height: 100%;
  56. max-width: 100%;
  57. }
  58. }
  59. .close {
  60. display: flex;
  61. align-items: center;
  62. justify-content: center;
  63. position: fixed;
  64. top: 20px;
  65. right: 20px;
  66. cursor: pointer;
  67. background: #333;
  68. border-radius: 50%;
  69. padding: 10px;
  70. opacity: 0.5;
  71. i {
  72. font-weight: bold;
  73. font-size: 20px;
  74. color: white;
  75. }
  76. }
  77. }
  78. </style>