index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <demo-section>
  3. <van-notice-bar>{{ $t('tips') }}</van-notice-bar>
  4. <demo-block :title="$t('basicUsage')">
  5. <p class="page-desc">{{ $t('text') }}</p>
  6. <ul
  7. v-waterfall-lower="loadMore"
  8. waterfall-disabled="disabled"
  9. waterfall-offset="400"
  10. >
  11. <li v-for="item in list">{{ item }}</li>
  12. </ul>
  13. </demo-block>
  14. </demo-section>
  15. </template>
  16. <script>
  17. import { Waterfall } from '../..';
  18. export default {
  19. i18n: {
  20. 'zh-CN': {
  21. text: '当即将滚动到元素底部时,会自动加载更多',
  22. tips: '注意:Waterfall 已被废弃,请使用 List 组件代替'
  23. },
  24. 'en-US': {
  25. text: 'This list will load items will scroll to bottom.',
  26. tips: 'Waterfall is deprecated and no longer maintained, please use the List component instead.'
  27. }
  28. },
  29. directives: {
  30. WaterfallLower: Waterfall('lower')
  31. },
  32. data() {
  33. return {
  34. list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
  35. disabled: false
  36. };
  37. },
  38. methods: {
  39. loadMore() {
  40. this.disabled = true;
  41. setTimeout(() => {
  42. for (let i = 0; i < 5; i++) {
  43. this.list.push(this.list.length);
  44. }
  45. this.disabled = false;
  46. }, 200);
  47. }
  48. }
  49. };
  50. </script>
  51. <style lang="less">
  52. @import '../../style/var';
  53. .demo-waterfall {
  54. ul {
  55. max-height: 360px;
  56. overflow: scroll;
  57. border-top: 1px solid @gray-light;
  58. }
  59. li {
  60. line-height: 50px;
  61. border-bottom: 1px solid @gray-light;
  62. background: @white;
  63. text-align: center;
  64. }
  65. .page-desc {
  66. padding: 5px 0;
  67. line-height: 1.4;
  68. font-size: 14px;
  69. text-align: center;
  70. color: @gray-darker;
  71. }
  72. }
  73. </style>