tui-grid-item.vue 2.5 KB

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