uni-list.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <!-- #ifndef APP-NVUE -->
  3. <view class="uni-list uni-border-top-bottom">
  4. <view v-if="border" class="uni-list--border-top"></view>
  5. <slot />
  6. <view v-if="border" class="uni-list--border-bottom"></view>
  7. </view>
  8. <!-- #endif -->
  9. <!-- #ifdef APP-NVUE -->
  10. <list class="uni-list" :class="{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop" loadmoreoffset="15"><slot /></list>
  11. <!-- #endif -->
  12. </template>
  13. <script>
  14. /**
  15. * List 列表
  16. * @description 列表组件
  17. * @tutorial https://ext.dcloud.net.cn/plugin?id=24
  18. * @property {String} border = [true|false] 标题
  19. */
  20. export default {
  21. name: 'uniList',
  22. 'mp-weixin': {
  23. options: {
  24. multipleSlots: false
  25. }
  26. },
  27. props: {
  28. enableBackToTop: {
  29. type: [Boolean, String],
  30. default: false
  31. },
  32. scrollY: {
  33. type: [Boolean, String],
  34. default: false
  35. },
  36. border: {
  37. type: Boolean,
  38. default: true
  39. }
  40. },
  41. // provide() {
  42. // return {
  43. // list: this
  44. // };
  45. // },
  46. created() {
  47. this.firstChildAppend = false;
  48. },
  49. methods: {
  50. loadMore(e) {
  51. this.$emit('scrolltolower');
  52. }
  53. }
  54. };
  55. </script>
  56. <style lang="scss" >
  57. $uni-bg-color:#ffffff;
  58. $uni-border-color:#e5e5e5;
  59. .uni-list {
  60. /* #ifndef APP-NVUE */
  61. display: flex;
  62. /* #endif */
  63. background-color: $uni-bg-color;
  64. position: relative;
  65. flex-direction: column;
  66. }
  67. .uni-list--border {
  68. position: relative;
  69. /* #ifdef APP-NVUE */
  70. border-top-color: $uni-border-color;
  71. border-top-style: solid;
  72. border-top-width: 0.5px;
  73. border-bottom-color: $uni-border-color;
  74. border-bottom-style: solid;
  75. border-bottom-width: 0.5px;
  76. /* #endif */
  77. z-index: -1;
  78. }
  79. /* #ifndef APP-NVUE */
  80. .uni-list--border-top {
  81. position: absolute;
  82. top: 0;
  83. right: 0;
  84. left: 0;
  85. height: 1px;
  86. -webkit-transform: scaleY(0.5);
  87. transform: scaleY(0.5);
  88. background-color: $uni-border-color;
  89. z-index: 1;
  90. }
  91. .uni-list--border-bottom {
  92. position: absolute;
  93. bottom: 0;
  94. right: 0;
  95. left: 0;
  96. height: 1px;
  97. -webkit-transform: scaleY(0.5);
  98. transform: scaleY(0.5);
  99. background-color: $uni-border-color;
  100. }
  101. /* #endif */
  102. </style>