imgbox.vue 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div :class="{ bigBox: state === 1 }">
  3. <popup :show="showPopup" @cancel="cancelFrom" />
  4. <div class="card" :class="{ flipped: state === 1 }" @click="showPopup=true">
  5. <div class="front">
  6. <img v-if="isFrist" :src="fristFontImg" class="nowimage" />
  7. <img v-else :src="nowFontImg" class="nowimage" />
  8. </div>
  9. <div class="back">
  10. <img v-if="state===1" :src="nowBackImg" class="nowimage" />
  11. <img v-else :src="openImg" class="nowimage" />
  12. </div>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. props: {
  19. value: {
  20. type: String,
  21. require: true,
  22. },
  23. },
  24. components: {
  25. Popup: () => import("@/components/Popup.vue"),
  26. },
  27. data() {
  28. return {
  29. showPopup: false,
  30. state: 1,
  31. classList: ["card"],
  32. fristFontImg:undefined,
  33. nowFontImg: require('../assets/popupImg/backImag.jpg'),
  34. nowBackImg: require('../assets/popupImg/popuBody.jpg'),
  35. openImg: require('../assets/popupImg/redBack.jpg'),
  36. isFrist:true,
  37. };
  38. },
  39. watch: {
  40. value: {
  41. handler(val) {
  42. if (val) {
  43. this.fristFontImg = val;
  44. }
  45. },
  46. immediate: true,
  47. },
  48. },
  49. methods: {
  50. transform() {
  51. this.showPopup=true
  52. this.state = Math.abs(this.state - 1);
  53. },
  54. cancelFrom() {
  55. this.state = Math.abs(this.state - 1);
  56. this.showPopup=false
  57. this.isFrist=false
  58. }
  59. },
  60. };
  61. </script>
  62. <style lang="less" scoped>
  63. .bigBox {
  64. perspective: 600px;
  65. overflow: hidden;
  66. }
  67. .card {
  68. position: relative;
  69. width: 22vw;
  70. height: 60.5vw;
  71. transform-style: preserve-3d;
  72. transition: all 1.6s ease;
  73. transform: rotateY(-180deg) scale(2);
  74. }
  75. .card > div {
  76. position: absolute;
  77. top: 0;
  78. left: 0;
  79. width: 100%;
  80. /* 背面不显示 */
  81. backface-visibility: hidden;
  82. }
  83. .flipped {
  84. transform: rotateY(0);
  85. }
  86. .nowimage {
  87. width: 22vw;
  88. height: 60.5vw;
  89. }
  90. .card .back {
  91. transform: rotateY(-180deg);
  92. }
  93. </style>>