main.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="basic-block"
  3. :style="styleName">
  4. <div class="box"
  5. :style="boxStyleName">
  6. <router-link :to="to">
  7. <span v-text="text"></span>
  8. <p v-text="dept"></p>
  9. <i :class="icon"></i>
  10. </router-link>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'basicBlock',
  17. props: {
  18. icon: {
  19. type: String,
  20. },
  21. background: {
  22. type: String,
  23. },
  24. to: {
  25. type: Object,
  26. default: () => {
  27. return {}
  28. }
  29. },
  30. text: {
  31. type: String,
  32. },
  33. dept: {
  34. type: String,
  35. },
  36. time: {
  37. type: [Number, String]
  38. },
  39. gutter: {
  40. type: [Number, String],
  41. default: 5,
  42. },
  43. color: {
  44. type: String,
  45. },
  46. width: {
  47. type: [Number, String]
  48. },
  49. height: {
  50. type: [Number, String]
  51. }
  52. },
  53. computed: {
  54. styleName () {
  55. return {
  56. animationDelay: `${this.time / 25}s`,
  57. width: this.setPx(this.width),
  58. height: this.setPx(this.height),
  59. margin: this.setPx(this.gutter)
  60. }
  61. },
  62. boxStyleName () {
  63. return {
  64. backgroundColor: this.color,
  65. backgroundImage: `url('${this.background}')`,
  66. }
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .basic-block {
  73. opacity: 0;
  74. box-sizing: border-box;
  75. color: #fff;
  76. animation: mymove 1s;
  77. animation-fill-mode: forwards;
  78. .box {
  79. position: relative;
  80. box-sizing: border-box;
  81. padding: 15px;
  82. width: 100%;
  83. height: 100%;
  84. transition: all 1s;
  85. background-size: cover;
  86. &:hover {
  87. transform: rotateY(360deg);
  88. }
  89. }
  90. a {
  91. color: #fff;
  92. }
  93. span {
  94. display: block;
  95. font-size: 16px;
  96. }
  97. p {
  98. width: 80%;
  99. font-size: 10px;
  100. color: #eee;
  101. line-height: 22px;
  102. }
  103. i {
  104. position: absolute;
  105. bottom: 15px;
  106. right: 15px;
  107. font-size: 50px !important ;
  108. }
  109. @keyframes mymove {
  110. from {
  111. opacity: 0;
  112. transform: scale(0);
  113. }
  114. to {
  115. opacity: 1;
  116. transform: scale(1);
  117. }
  118. }
  119. }
  120. </style>