tabBar.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="tabBar">
  3. <van-tabbar
  4. v-model="ActiveMessage"
  5. @change="tabBarChange"
  6. active-color="#0057ba"
  7. inactive-color="#222">
  8. <van-tabbar-item name="home">
  9. <span>首页</span>
  10. <template #icon>
  11. <van-icon
  12. :name="
  13. tabBarActive == 'home'
  14. ? require('@/assets/icon/hone-select.png')
  15. : require('@/assets/icon/home.png')
  16. " />
  17. </template>
  18. </van-tabbar-item>
  19. <van-tabbar-item name="agentList">
  20. <span>经销商</span>
  21. <template #icon>
  22. <van-icon :name="tabBarActive == 'agentList' ? activedChain : chains" />
  23. </template>
  24. </van-tabbar-item>
  25. <van-tabbar-item name="info">
  26. <span>我的</span>
  27. <template #icon>
  28. <van-icon :name="tabBarActive == 'info' ? activedInfo : info" />
  29. </template>
  30. </van-tabbar-item>
  31. </van-tabbar>
  32. </div>
  33. </template>
  34. <script>
  35. import chains from '@/assets/icon/chain.svg';
  36. import activedChain from '@/assets/icon/activedChain.svg';
  37. import info from '@/assets/icon/info.svg';
  38. import activedInfo from '@/assets/icon/activedInfo.svg';
  39. export default {
  40. name: 'tabBar',
  41. props: {
  42. tabBarActive: {
  43. type: String,
  44. default: 'home',
  45. },
  46. },
  47. data() {
  48. return {
  49. chains: chains,
  50. activedChain: activedChain,
  51. info: info,
  52. activedInfo: activedInfo,
  53. tabBarAct: this.tabBarActive,
  54. show: false,
  55. };
  56. },
  57. computed: {
  58. ActiveMessage: {
  59. get() {
  60. return (this.tabBarAct = this.tabBarActive);
  61. },
  62. set(newValue) {
  63. return newValue;
  64. },
  65. },
  66. },
  67. methods: {
  68. tabBarChange(index) {
  69. this.$router.push({ name: index + '' });
  70. },
  71. },
  72. };
  73. </script>
  74. <style lang="scss">
  75. .tabBar {
  76. z-index: 9999;
  77. }
  78. </style>