list-cell.vue 2.3 KB

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