nested-scroll-header.uvue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <scroll-view style="flex:1" type="nested" direction="vertical">
  3. <nested-scroll-header>
  4. <view class="scroll-header-tiem1">
  5. <text>会渲染的nested-scroll-header</text>
  6. </view>
  7. <view class="scroll-header-tiem1">
  8. <text>不会渲染nested-scroll-header,因为 nested-scroll-header 只会渲染第一个子节点</text>
  9. </view>
  10. </nested-scroll-header>
  11. <nested-scroll-header>
  12. <swiper ref="header" indicator-dots="true" circular="true">
  13. <swiper-item v-for="i in num" :item-id="i">
  14. <view class="scroll-header-tiem2">
  15. <text>如果存在多个头部节点,那么就使用多个 nested-scroll-header 来将其包裹</text>
  16. </view>
  17. </swiper-item>
  18. </swiper>
  19. </nested-scroll-header>
  20. <nested-scroll-body>
  21. <scroll-view style="flex:1" associative-container="nested-scroll-view">
  22. <view v-for="key in scrollData">
  23. <view class="scroll-item">
  24. <text class="scroll-item-title">{{key}}</text>
  25. </view>
  26. </view>
  27. </scroll-view>
  28. </nested-scroll-body>
  29. </scroll-view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. scrollData: [] as Array<string>,
  36. num: 0,
  37. }
  38. },
  39. onLoad() {
  40. let lists : Array<string> = []
  41. for (let i = 0; i < 30; i++) {
  42. lists.push("item---" + i)
  43. }
  44. this.scrollData = lists
  45. },
  46. onReady() {
  47. this.num = 3
  48. },
  49. methods: {
  50. }
  51. }
  52. </script>
  53. <style>
  54. .scroll-item {
  55. margin-left: 6px;
  56. margin-right: 6px;
  57. margin-top: 6px;
  58. background-color: #fff;
  59. border-radius: 4px;
  60. }
  61. .scroll-item-title {
  62. width: 100%;
  63. height: 60px;
  64. line-height: 60px;
  65. text-align: center;
  66. color: #555;
  67. }
  68. .scroll-header-tiem1 {
  69. height: 200px;
  70. background-color: #66ccff;
  71. align-items: center;
  72. justify-content: center;
  73. }
  74. .scroll-header-tiem2 {
  75. height: 100px;
  76. background-color: #89ff8d;
  77. align-items: center;
  78. justify-content: center;
  79. }
  80. </style>