grid-item.vue 2.2 KB

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