demo.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="demo full">
  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="pull-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="pull-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. width: 100%;
  77. }
  78. .content {
  79. height: 100%;
  80. overflow: auto;
  81. }
  82. .horizontal {
  83. width: 100%;
  84. }
  85. .contentH {
  86. height: 100px;
  87. overflow: auto;
  88. .mainH {
  89. display: flex;
  90. height: 100%;
  91. .pull-data {
  92. flex-shrink: 0;
  93. display: flex;
  94. align-items: center;
  95. height: 90%;
  96. width: 120px;
  97. justify-content: center;
  98. padding: 0;
  99. margin: 2px 10px 0 0;
  100. background: white;
  101. border-radius: 7px;
  102. box-shadow: 0px 1px 7px 0px #edeef1;
  103. line-height: 19px;
  104. font-size: 13px;
  105. color: #666666;
  106. }
  107. }
  108. }
  109. .content {
  110. .main {
  111. .pull-data {
  112. margin: 15px auto 20px;
  113. padding-left: 16px;
  114. display: flex;
  115. align-items: center;
  116. width: 100%;
  117. height: 46px;
  118. background: rgba(255, 255, 255, 1);
  119. border-radius: 7px;
  120. box-shadow: 0px 1px 7px 0px rgba(237, 238, 241, 1);
  121. line-height: 19px;
  122. font-size: 13px;
  123. color: rgba(102, 102, 102, 1);
  124. &:first-child {
  125. margin-top: 0 !important;
  126. }
  127. &:last-child {
  128. margin-bottom: 0 !important;
  129. }
  130. }
  131. }
  132. }
  133. </style>