IndexBar.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="index_bar flex-column">
  3. <div :class="index==current?'active':''" v-for="(item,index) in index_data" :key="index"
  4. @click="inBarChange(index)">
  5. {{item}}</div>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. props: {
  11. current: {
  12. type: Number || String,
  13. default: 0
  14. },
  15. index_data: {
  16. type: Array,
  17. default: () => {
  18. return ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'M', 'N', 'O', 'P', 'Q', 'R',
  19. 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
  20. ]
  21. }
  22. },
  23. },
  24. methods: {
  25. inBarChange(index) {
  26. let obj = {
  27. index: index,
  28. text: this.index_data[index]
  29. }
  30. this.$emit('change', obj)
  31. }
  32. }
  33. }
  34. </script>
  35. <style lang="scss" scoped>
  36. @import '../style/common.scss';
  37. .index_bar {
  38. width: 100%;
  39. div {
  40. font-size: 16px;
  41. font-family: PingFang SC;
  42. font-weight: 400;
  43. color: #333333;
  44. cursor: pointer;
  45. margin-bottom: 5px;
  46. margin: 0 auto 3px;
  47. }
  48. .active {
  49. width: 22px;
  50. height: 22px;
  51. background: #16D1BA;
  52. border-radius: 2px;
  53. color: #fff;
  54. text-align: center;
  55. }
  56. }
  57. </style>