categoryList.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="category-list warp" :class="'terminal' + terminal">
  3. <h2 class="hom-title" :style="{textAlign:componentContent.textAlign}">{{componentContent.title}}</h2>
  4. <div class="content-warp">
  5. <ul class="clearfix" :class="{number5: componentContent.categoryData.length === 5}">
  6. <li v-for="(item) of componentContent.categoryData" :key="item.id">
  7. <a class="item a-link" @click="jumpCategory(item)">
  8. <div class="imgBox">
  9. <img ref="getHeight" :src="item.img" v-show="item.img" :alt="item.name">
  10. </div>
  11. </a>
  12. </li>
  13. </ul>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import {funMixin} from '../config/mixin'
  19. export default {
  20. name: 'categoryList',
  21. mixins: [funMixin],
  22. props: {
  23. terminal: {
  24. type: Number,
  25. default: 4
  26. },
  27. componentContent: {
  28. type: Object
  29. }
  30. }
  31. }
  32. </script>
  33. <style lang="scss" scoped>
  34. .category-list{
  35. padding: 20px 0;
  36. .hom-title{
  37. font-size: 22px;
  38. color: #333;
  39. line-height: 1em;
  40. margin-bottom: 23px;
  41. font-weight: bold;
  42. text-align: center;
  43. }
  44. .content-warp{
  45. display: flex;
  46. ul{
  47. width: 100%;
  48. display: flex;
  49. flex-wrap: wrap;
  50. li{
  51. flex: 1;
  52. padding: 10px 0 0 10px;
  53. .item{
  54. height: auto;
  55. display: flex;
  56. flex-direction: column;
  57. justify-content: center;
  58. .imgBox {
  59. padding-bottom: 80%;
  60. background-color: #cacaca;
  61. position: relative;
  62. }
  63. img {
  64. max-width: 100%;
  65. height: 100%;
  66. max-height: 100%;
  67. position: absolute;
  68. margin: auto;
  69. top: 0;
  70. right: 0;
  71. bottom: 0;
  72. left: 0;
  73. }
  74. }
  75. }
  76. }
  77. .number5 {
  78. display: block;
  79. li {
  80. width: 25%;
  81. float: left;
  82. }
  83. li:nth-child(1) {
  84. width: 50%;
  85. }
  86. }
  87. }
  88. }
  89. @media screen and (max-width: 768px) {
  90. .category-list .content-warp{
  91. display: block;
  92. ul{
  93. margin: -15px 0 0 -15px;
  94. width: auto;
  95. li{
  96. flex: 0 0 50%;
  97. padding: 15px 0 0 15px;
  98. }
  99. }
  100. }
  101. }
  102. .terminal1,.terminal2,.terminal3{
  103. &.category-list .content-warp{
  104. display: block;
  105. ul{
  106. margin: -15px 0 0 -15px;
  107. width: auto;
  108. li{
  109. flex: 0 0 50%;
  110. padding: 15px 0 0 15px;
  111. }
  112. }
  113. }
  114. }
  115. </style>