tui-grid-item.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. .tui-grid-2 {
  60. width: 50%;
  61. }
  62. .tui-grid-3 {
  63. width: 33.333333333%;
  64. }
  65. .tui-grid-4 {
  66. width: 25%;
  67. padding: 30rpx 20rpx !important;
  68. }
  69. .tui-grid-5 {
  70. width: 20%;
  71. padding: 20rpx !important;
  72. }
  73. .tui-grid-2:nth-of-type(2n)::before {
  74. width: 0;
  75. border-right: 0;
  76. }
  77. .tui-grid-3:nth-of-type(3n)::before {
  78. width: 0;
  79. border-right: 0;
  80. }
  81. .tui-grid-4:nth-of-type(4n)::before {
  82. width: 0;
  83. border-right: 0;
  84. }
  85. .tui-grid-5:nth-of-type(5n)::before {
  86. width: 0;
  87. border-right: 0;
  88. }
  89. .tui-grid::before {
  90. content: " ";
  91. position: absolute;
  92. right: 0;
  93. top: 0;
  94. width: 1px;
  95. bottom: 0;
  96. border-right: 1px solid #eaeef1;
  97. -webkit-transform-origin: 100% 0;
  98. transform-origin: 100% 0;
  99. -webkit-transform: scaleX(0.5);
  100. transform: scaleX(0.5);
  101. }
  102. .tui-grid__unlined::before{
  103. width: 0 !important;
  104. border-right: 0 !important;
  105. }
  106. .tui-grid::after {
  107. content: " ";
  108. position: absolute;
  109. left: 0;
  110. bottom: 0;
  111. right: 0;
  112. height: 1px;
  113. border-bottom: 1px solid #eaeef1;
  114. -webkit-transform-origin: 0 100%;
  115. transform-origin: 0 100%;
  116. -webkit-transform: scaleY(0.5);
  117. transform: scaleY(0.5);
  118. }
  119. .tui-grid-bottom::after {
  120. height: 0 !important;
  121. border-bottom: 0 !important
  122. }
  123. .tui-grid-bg {
  124. position: relative;
  125. padding: 0;
  126. width: 100%;
  127. box-sizing: border-box;
  128. }
  129. .tui-item-hover {
  130. background-color: #f7f7f9 !important;
  131. }
  132. </style>