tui-grid-item.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="tui-grid" :class="[bottomLine?'':'tui-grid-bottom',border?'':'tui-grid__unlined','tui-grid-'+(cell<2?3:cell)]" :hover-class="hover?'tui-item-hover':''"
  3. :hover-stay-time="150" :style="{backgroundColor:backgroundColor}" @tap="handleClick">
  4. <view class='tui-grid-bg'>
  5. <slot></slot>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: "tuiGridItem",
  12. props: {
  13. cell: {
  14. type: [Number,String],
  15. default: 3
  16. },
  17. backgroundColor: {
  18. type: String,
  19. default: "#fff"
  20. },
  21. //是否有点击效果
  22. hover: {
  23. type: Boolean,
  24. default: true
  25. },
  26. //是否需要底部线条
  27. bottomLine: {
  28. type: Boolean,
  29. default: true
  30. },
  31. //是否需要纵向边框线条
  32. border:{
  33. type: Boolean,
  34. default: true
  35. },
  36. index: {
  37. type: Number,
  38. default: 0
  39. }
  40. },
  41. methods: {
  42. handleClick() {
  43. this.$emit('click', {
  44. index: this.index
  45. });
  46. }
  47. }
  48. }
  49. </script>
  50. <style scoped>
  51. .tui-grid {
  52. position: relative;
  53. padding: 40rpx 20rpx;
  54. box-sizing: border-box;
  55. background: #fff;
  56. float: left;
  57. }
  58. .tui-grid-2 {
  59. width: 50%;
  60. }
  61. .tui-grid-3 {
  62. width: 33.333333333%;
  63. }
  64. .tui-grid-4 {
  65. width: 25%;
  66. padding: 30rpx 20rpx !important;
  67. }
  68. .tui-grid-5 {
  69. width: 20%;
  70. padding: 20rpx !important;
  71. }
  72. .tui-grid-2:nth-of-type(2n)::before {
  73. width: 0;
  74. border-right: 0;
  75. }
  76. .tui-grid-3:nth-of-type(3n)::before {
  77. width: 0;
  78. border-right: 0;
  79. }
  80. .tui-grid-4:nth-of-type(4n)::before {
  81. width: 0;
  82. border-right: 0;
  83. }
  84. .tui-grid-5:nth-of-type(5n)::before {
  85. width: 0;
  86. border-right: 0;
  87. }
  88. .tui-grid::before {
  89. content: " ";
  90. position: absolute;
  91. right: 0;
  92. top: 0;
  93. width: 1px;
  94. bottom: 0;
  95. border-right: 1px solid #eaeef1;
  96. -webkit-transform-origin: 100% 0;
  97. transform-origin: 100% 0;
  98. -webkit-transform: scaleX(0.5);
  99. transform: scaleX(0.5);
  100. }
  101. .tui-grid__unlined::before{
  102. width: 0 !important;
  103. border-right: 0 !important;
  104. }
  105. .tui-grid::after {
  106. content: " ";
  107. position: absolute;
  108. left: 0;
  109. bottom: 0;
  110. right: 0;
  111. height: 1px;
  112. border-bottom: 1px solid #eaeef1;
  113. -webkit-transform-origin: 0 100%;
  114. transform-origin: 0 100%;
  115. -webkit-transform: scaleY(0.5);
  116. transform: scaleY(0.5);
  117. }
  118. .tui-grid-bottom::after {
  119. height: 0 !important;
  120. border-bottom: 0 !important
  121. }
  122. .tui-grid-bg {
  123. position: relative;
  124. padding: 0;
  125. width: 100%;
  126. box-sizing: border-box;
  127. }
  128. .tui-item-hover {
  129. background-color: #f7f7f9 !important;
  130. }
  131. </style>