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.
 
 
 
 
 
 

76 lines
1.3 KiB

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