demo.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="demo">
  3. <h2>纵向</h2>
  4. <nut-cell>
  5. <div class="vertical">
  6. <nut-pullrefresh
  7. @refresh="refresh"
  8. @down-refresh="downRefresh"
  9. :useWindow="false"
  10. containerId="pull"
  11. >
  12. <div class="content" id="pull">
  13. <div class="main">
  14. <div
  15. class="text-data"
  16. v-for="item in [1, 2, 3, 4, 5, 6, 7, 8, 9]"
  17. :key="item"
  18. >我是测试数据 {{ item }}</div
  19. >
  20. </div>
  21. </div>
  22. </nut-pullrefresh>
  23. </div>
  24. </nut-cell>
  25. <h2>横向</h2>
  26. <nut-cell>
  27. <div class="horizontal">
  28. <nut-pullrefresh
  29. @refresh="refresh"
  30. @down-refresh="downRefresh"
  31. :useWindow="false"
  32. containerId="pullH"
  33. direction="horizontal"
  34. >
  35. <div class="contentH" id="pullH">
  36. <div class="mainH">
  37. <div
  38. class="text-data"
  39. v-for="item in [1, 2, 3, 4, 5, 6, 7, 8, 9]"
  40. :key="item"
  41. >我是测试数据 {{ item }}</div
  42. >
  43. </div>
  44. </div>
  45. </nut-pullrefresh>
  46. </div>
  47. </nut-cell>
  48. </div>
  49. </template>
  50. <script lang="ts">
  51. import { createComponent } from '@/utils/create';
  52. const { createDemo } = createComponent('pullrefresh');
  53. export default createDemo({
  54. props: {},
  55. setup() {
  56. const refresh = done => {
  57. console.log('上拉加载');
  58. setTimeout(() => {
  59. done();
  60. }, 1000);
  61. };
  62. const downRefresh = done => {
  63. console.log('下拉刷新');
  64. setTimeout(() => {
  65. done();
  66. }, 1000);
  67. };
  68. return { refresh, downRefresh };
  69. }
  70. });
  71. </script>
  72. <style lang="scss" scoped>
  73. .vertical {
  74. height: 300px;
  75. overflow: hidden;
  76. }
  77. .content {
  78. height: 100%;
  79. overflow: auto;
  80. }
  81. .horizontal {
  82. width: 100%;
  83. }
  84. .contentH {
  85. height: 100px;
  86. overflow: auto;
  87. .mainH {
  88. display: flex;
  89. height: 100%;
  90. .text-data {
  91. height: 90% !important;
  92. width: 120px !important;
  93. flex-shrink: 0;
  94. padding: 0 !important;
  95. margin: 2px 10px 0 0 !important;
  96. justify-content: center;
  97. }
  98. }
  99. }
  100. .content {
  101. .main {
  102. .text-data {
  103. &:first-child {
  104. margin-top: 0 !important;
  105. }
  106. &:last-child {
  107. margin-bottom: 0 !important;
  108. }
  109. }
  110. }
  111. }
  112. </style>