index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="bottom_tabbar">
  3. <view v-for="(item,index) in list" :key="index" @tap="changeTabbar(index)">
  4. <image :src="tabbarIndex===index?item.activeImg:item.inactiveImg"></image>
  5. <text :class="{'active':tabbarIndex===index}">{{item.text}}</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. tabbarIndex: 0
  13. },
  14. data() {
  15. return {
  16. tabbarValue: 0,
  17. list: [
  18. {
  19. inactiveImg: require('@/static/tab_home.png'),
  20. activeImg: require('@/static/tab_home_active.png'),
  21. text: '首页',
  22. path: '/pages/home'
  23. },
  24. {
  25. inactiveImg: require('@/static/tab_my.png'),
  26. activeImg: require('@/static/tab_my_active.png'),
  27. text: '我的',
  28. path: '/pages/my'
  29. }
  30. ],
  31. loginSuccessUrl:''
  32. }
  33. },
  34. mounted() {
  35. this.tabbarValue = this.tabbarIndex;
  36. },
  37. methods: {
  38. changeTabbar(e) {
  39. this.tabbarValue = e;
  40. uni.reLaunch({
  41. url: this.list[e].path
  42. })
  43. }
  44. }
  45. }
  46. </script>
  47. <style scoped lang="less">
  48. .bottom_tabbar {
  49. width: 100%;
  50. height: 172rpx;
  51. background: #FFFFFF;
  52. display: flex;
  53. position: fixed;
  54. left: 0;
  55. bottom: 0;
  56. z-index: 999;
  57. padding-top: 18rpx;
  58. box-sizing: border-box;
  59. box-shadow: 0rpx -2rpx 8rpx 0rpx rgba(0,0,0,0.06);
  60. &>view {
  61. width: calc(100% / 2);
  62. height: 100%;
  63. display: flex;
  64. flex-direction: column;
  65. align-items: center;
  66. image {
  67. width: 48rpx;
  68. height: 48rpx;
  69. }
  70. text {
  71. margin-top: 12rpx;
  72. font-family: PingFangSC, PingFang SC;
  73. font-weight: 400;
  74. font-size: 22rpx;
  75. color: #808080;
  76. line-height: 22rpx;
  77. text-align: center;
  78. &.active{
  79. font-weight: bold;
  80. color: #761E6A;
  81. }
  82. }
  83. }
  84. }
  85. </style>