You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
1.3 KiB

  1. <template>
  2. <scroll-view
  3. :scroll-left="scrollLeft"
  4. :class="['bg-' + color, type === 'center' ? 'text-center' : '', shadow ? 'nav-shadow' : '', className]"
  5. :style="style"
  6. class="nav"
  7. style="z-index: 10;"
  8. scroll-with-animation
  9. scroll-x
  10. >
  11. <template v-if="type !== 'flex'">
  12. <view
  13. v-for="(item, idx) in items"
  14. @tap="tabSelect(idx)"
  15. :class="value === idx ? 'text-green cur' : ''"
  16. :key="idx"
  17. class="cu-item"
  18. >
  19. {{ item }}
  20. </view>
  21. </template>
  22. <view v-else class="flex text-center">
  23. <view
  24. @tap="tabSelect(idx)"
  25. v-for="(item, idx) in items"
  26. :key="idx"
  27. :class="[value === idx ? (color ? 'bg-white cur' : 'bg-green cur') : '']"
  28. class="cu-item flex-sub"
  29. >
  30. {{ item }}
  31. </view>
  32. </view>
  33. </scroll-view>
  34. </template>
  35. <script>
  36. export default {
  37. name: 'l-nav',
  38. props: {
  39. color: { default: 'white' },
  40. items: { default: () => [] },
  41. value: {},
  42. type: { default: 'default' },
  43. shadow: {}
  44. },
  45. data() {
  46. return {
  47. scrollLeft: 0
  48. }
  49. },
  50. methods: {
  51. tabSelect(idx) {
  52. this.scrollLeft = (idx - 1) * 60
  53. this.$emit('input', idx)
  54. this.$emit('change', idx)
  55. }
  56. }
  57. }
  58. </script>
  59. <style scoped>
  60. .nav-shodow {
  61. box-shadow: 0px 0px 7px 0px #666;
  62. }
  63. </style>