index.vue 900 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <u-index-list :scrollTop="scrollTop" :index-list="indexList">
  3. <view v-for="(item, index) in list" :key="index">
  4. <u-index-anchor :index="item.letter" />
  5. <view class="list-cell u-border-bottom" v-for="(item1, index) in item.data" :key="index">
  6. {{item1.name}}
  7. </view>
  8. </view>
  9. </u-index-list>
  10. </template>
  11. <script>
  12. import indexList from "@/common/index.list.js";
  13. const letterArr = indexList.list.map(val => {
  14. return val.letter;
  15. })
  16. export default {
  17. data() {
  18. return {
  19. scrollTop: 0,
  20. indexList: letterArr,
  21. list: indexList.list
  22. }
  23. },
  24. onPageScroll(e) {
  25. this.scrollTop = e.scrollTop;
  26. }
  27. }
  28. </script>
  29. <style lang="scss" scoped>
  30. .list-cell {
  31. display: flex;
  32. box-sizing: border-box;
  33. width: 100%;
  34. padding: 10px 24rpx;
  35. overflow: hidden;
  36. color: $u-content-color;
  37. font-size: 14px;
  38. line-height: 24px;
  39. background-color: #fff;
  40. }
  41. </style>