index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <view class="tab-bar">
  3. <view class="content">
  4. <view class="one-tab" v-for="(item, index) in tabBarList" :key="index" @click="selectTabBar(item.pagePath)">
  5. <view class="tabItem">
  6. <view class="tabItem_c" v-if="routePath === item.pagePath">
  7. </view>
  8. <view>
  9. <view class="tab-img">
  10. <image v-if="routePath === item.pagePath" class="img" :src="item.selectedIconPath"></image>
  11. <image v-else class="img" :src="item.iconPath"></image>
  12. </view>
  13. </view>
  14. <view v-if="routePath === item.pagePath" class="tit selectTexts">{{ item.text }}</view>
  15. <view v-else class="tit texts">{{ item.text }}</view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. props: {
  24. // 底部导航栏数据
  25. tabBarList: {
  26. type: Array,
  27. required: true
  28. },
  29. // 当前页面路径
  30. routePath: {
  31. type: String,
  32. required: true
  33. }
  34. },
  35. data() {
  36. return {};
  37. },
  38. methods: {
  39. selectTabBar(path) {
  40. this.$emit('onTabBar', path)
  41. }
  42. },
  43. created() {
  44. console.log('tabBarList----', this.tabBarList);
  45. console.log('routePath---', this.routePath);
  46. }
  47. };
  48. </script>
  49. <style lang="scss" scoped>
  50. @import "./index.scss";
  51. </style>