scroller.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div>
  3. <nut-docheader
  4. :name="$route.name"
  5. :showQrCode="true"></nut-docheader>
  6. <h5>示例</h5>
  7. <div class="scroller-container">
  8. <nut-scroller
  9. :on-refresh="onRefresh"
  10. :on-infinite="onInfinite">
  11. <div v-for="(item, index) in list" :key="index" class="content-item">{{'滚动区域的内容' + (index + 1)}}</div>
  12. </nut-scroller>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. list: [...Array(15)]
  21. };
  22. },
  23. methods: {
  24. onRefresh(done) {
  25. setTimeout(() => {
  26. this.list = [...Array(15)]
  27. done()
  28. }, 2000)
  29. },
  30. onInfinite(done) {
  31. setTimeout(() => {
  32. if (this.list && this.list.length < 35) {
  33. this.list = [...this.list, ...Array(15)]
  34. }
  35. done()
  36. }, 2000)
  37. }
  38. }
  39. };
  40. </script>
  41. <style lang="scss">
  42. .scroller-container {
  43. position: relative;
  44. width: 100%;
  45. height: 500px;
  46. background: #f2f2f2;
  47. }
  48. .content-item {
  49. padding: 5px;
  50. line-height: 20px;
  51. background: #cccccc;
  52. margin-bottom: 10px;
  53. font-size: 14px;
  54. }
  55. </style>