uni-list.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-list {
  58. /* #ifndef APP-NVUE */
  59. display: flex;
  60. /* #endif */
  61. background-color: $uni-bg-color;
  62. position: relative;
  63. flex-direction: column;
  64. }
  65. .uni-list--border {
  66. position: relative;
  67. /* #ifdef APP-NVUE */
  68. border-top-color: $uni-border-color;
  69. border-top-style: solid;
  70. border-top-width: 0.5px;
  71. border-bottom-color: $uni-border-color;
  72. border-bottom-style: solid;
  73. border-bottom-width: 0.5px;
  74. /* #endif */
  75. z-index: -1;
  76. }
  77. /* #ifndef APP-NVUE */
  78. .uni-list--border-top {
  79. position: absolute;
  80. top: 0;
  81. right: 0;
  82. left: 0;
  83. height: 1px;
  84. -webkit-transform: scaleY(0.5);
  85. transform: scaleY(0.5);
  86. background-color: $uni-border-color;
  87. z-index: 1;
  88. }
  89. .uni-list--border-bottom {
  90. position: absolute;
  91. bottom: 0;
  92. right: 0;
  93. left: 0;
  94. height: 1px;
  95. -webkit-transform: scaleY(0.5);
  96. transform: scaleY(0.5);
  97. background-color: $uni-border-color;
  98. }
  99. /* #endif */
  100. </style>