Tabbar.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template >
  2. <view>
  3. <u-tabbar v-model="myCurrent" :list="tabbarList"
  4. :before-switch="beforeSwitch"
  5. :mid-button="true" active-color="#1677ff"></u-tabbar>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name:"tabbarJob",
  11. props:{
  12. current: 0
  13. },
  14. data() {
  15. return {
  16. activeColor:"#5098FF",
  17. oldindex:this.current,
  18. myCurrent:this.current,
  19. tabbarList: [{
  20. iconPath: "motuoche-diandongche",
  21. selectedIconPath: "motuoche-diandongche",
  22. text: '充电中',
  23. count: 0,
  24. isDot: true,
  25. customIcon: true,
  26. pagePath2:"/pages/index/index?k=1",
  27. },
  28. {
  29. iconPath: "/static/img/min_button_select.png",
  30. selectedIconPath: "/static/img/min_button_select.png",
  31. text: '充电',
  32. midButton: true,
  33. customIcon: true,
  34. pagePath2:"/pages/charge/index",
  35. },
  36. {
  37. iconPath: "31wode",
  38. selectedIconPath: "31wode",
  39. text: '我的',
  40. count: 0,
  41. isDot: false,
  42. customIcon: true,
  43. pagePath2:"/pages/user/index",
  44. },
  45. ],
  46. };
  47. },methods:{
  48. beforeSwitch(index){
  49. var tabbarList= [{
  50. iconPath: "motuoche-diandongche",
  51. selectedIconPath: "motuoche-diandongche",
  52. text: '充电中',
  53. count: 0,
  54. isDot: true,
  55. customIcon: true,
  56. pagePath2:"/pages/index/index?k=1",
  57. },
  58. {
  59. iconPath: "/static/img/min_button_select.png",
  60. selectedIconPath: "/static/img/min_button_select.png",
  61. text: '充电',
  62. midButton: true,
  63. customIcon: true,
  64. pagePath2:"/pages/charge/index",
  65. },
  66. {
  67. iconPath: "31wode",
  68. selectedIconPath: "31wode",
  69. text: '我的',
  70. count: 0,
  71. isDot: false,
  72. customIcon: true,
  73. pagePath2:"/pages/user/index",
  74. },
  75. ]
  76. if(index==this.current){
  77. return false
  78. }
  79. //console.log(this.tabbarList)
  80. var url =tabbarList[index].pagePath2;
  81. uni.navigateTo({
  82. url: url
  83. })
  84. if(index==1){
  85. this.myCurrent=this.oldindex;
  86. return false;
  87. }else{
  88. return true;
  89. }
  90. },
  91. },mounted(){
  92. console.log(this.tabbarList)
  93. },destroyed(){
  94. }
  95. }
  96. </script>
  97. <style>
  98. </style>