tabbar.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="u-page">
  3. <view class="u-page__item">
  4. <u-gap height="150"></u-gap>
  5. <u-tabbar :value="value" @change='name => value = name' :fixed="true" :placeholder="true"
  6. :safeAreaInsetBottom="true">
  7. <u-tabbar-item @click='changeRouter(value,item)' v-for="item in tabbarList " :key="item.icon"
  8. :text="item.text" :icon="item.icon">
  9. </u-tabbar-item>
  10. </u-tabbar>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. props: {
  17. value:{
  18. type:Number,
  19. default:0
  20. },
  21. },
  22. data() {
  23. return {
  24. // value: 0,
  25. tabbarList: [{
  26. text: "房间",
  27. icon: "home",
  28. path:'/pages/tabbar/room/room'
  29. },
  30. {
  31. text: "网关",
  32. icon: "order",
  33. path:'/pages/tabbar/gateway/gateway'
  34. },
  35. {
  36. text: "首页",
  37. icon: "grid",
  38. path:'/pages/tabbar/index/index'
  39. },
  40. {
  41. text: "蓝牙",
  42. icon: "play-right",
  43. path:'/pages/tabbar/Bluetooth/Bluetooth'
  44. },
  45. {
  46. text: "我的",
  47. icon: "account",
  48. path:'/pages/tabbar/mine/mine'
  49. }
  50. ]
  51. }
  52. },
  53. methods: {
  54. changeRouter(value,item) {
  55. console.log(value,item);
  56. this.value=value
  57. uni.redirectTo({
  58. url:item.path
  59. })
  60. // if(value==1){
  61. // uni.redirectTo({
  62. // url:"/pages/tabbar/gateway/gateway?id="+1
  63. // })
  64. // }
  65. }
  66. },
  67. }
  68. </script>
  69. <style lang="scss">
  70. .u-page {
  71. padding: 0;
  72. &__item {
  73. &__title {
  74. color: $u-tips-color;
  75. background-color: $u-bg-color;
  76. padding: 15px;
  77. font-size: 15px;
  78. &__slot-title {
  79. color: $u-primary;
  80. font-size: 14px;
  81. }
  82. }
  83. &__slot-icon {
  84. width: 17px;
  85. height: 17px;
  86. }
  87. }
  88. }
  89. </style>