list-cell.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="tui-cell-class tui-list-cell" :class="{'tui-cell-arrow':arrow,'tui-cell-last':last,'tui-line-left':lineLeft,'tui-line-right':lineRight,'tui-radius':radius}" :hover-class="hover?'tui-cell-hover':''" :style="{background: bgcolor,fontSize: size+'rpx',color:color,padding:padding}" :hover-stay-time="150" @tap="handleClick">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'tuiListCell',
  9. props: {
  10. // 是否有箭头
  11. arrow: {
  12. type: Boolean,
  13. default: false
  14. },
  15. // 是否有点击效果
  16. hover: {
  17. type: Boolean,
  18. default: true
  19. },
  20. // left 30rpx
  21. lineLeft: {
  22. type: Boolean,
  23. default: true
  24. },
  25. // right 30rpx
  26. lineRight: {
  27. type: Boolean,
  28. default: true
  29. },
  30. padding: {
  31. type: String,
  32. default: '26rpx 30rpx'
  33. },
  34. last: {
  35. type: Boolean,
  36. default: false // 最后一条数据隐藏线条
  37. },
  38. radius: {
  39. type: Boolean,
  40. default: false
  41. },
  42. bgcolor: {
  43. type: String,
  44. default: '#fff' // 背景颜色
  45. },
  46. size: {
  47. type: Number,
  48. default: 28 // 字体大小
  49. },
  50. color: {
  51. type: String,
  52. default: '#333' // 字体颜色
  53. },
  54. index: {
  55. type: Number,
  56. default: 0
  57. }
  58. },
  59. methods: {
  60. handleClick() {
  61. this.$emit('click', {
  62. index: this.index
  63. })
  64. }
  65. }
  66. }
  67. </script>
  68. <style scoped>
  69. .tui-list-cell {
  70. position: relative;
  71. width: 100%;
  72. box-sizing: border-box;
  73. overflow: hidden;
  74. display: flex;
  75. align-items: center;
  76. }
  77. .tui-radius {
  78. border-radius: 12upx;
  79. overflow: hidden;
  80. }
  81. .tui-cell-hover {
  82. background: #f7f7f9 !important;
  83. }
  84. .tui-list-cell::after {
  85. content: '';
  86. position: absolute;
  87. border-bottom: 2px solid #eee;
  88. -webkit-transform: scaleY(0.5);
  89. transform: scaleY(0.5);
  90. bottom: 0;
  91. right: 0;
  92. left: 0;
  93. }
  94. .tui-line-left::after {
  95. left: 30rpx !important;
  96. }
  97. .tui-line-right::after {
  98. right: 30rpx !important;
  99. }
  100. .tui-cell-last::after {
  101. border-bottom: 0 !important;
  102. }
  103. .tui-list-cell.tui-cell-arrow:before {
  104. content: ' ';
  105. height: 22upx;
  106. width: 22upx;
  107. border-width: 2px 2px 0 0;
  108. border-color: #b2b2b2;
  109. border-style: solid;
  110. -webkit-transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  111. transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  112. position: absolute;
  113. top: 50%;
  114. margin-top: -12upx;
  115. right: 30upx;
  116. }
  117. </style>