tarbar.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="tarbar">
  3. <view v-for='(item,index) in datas' @tap="tabClick(index,item.urls,item.id)">
  4. <!-- <u-icon :color="item.color" :name="item.icon" size="60"></u-icon> -->
  5. <image v-if='i==index' style='width:40rpx;height:40rpx;margin-top:10rpx;' :src='item.actionIcon'></image>
  6. <image v-else style='width:40rpx;height:40rpx;margin-top:10rpx;' :src='item.icon'></image>
  7. <view v-text="item.name"></view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props:["totarBer"],//从父组件传来的值 来控制点击当前的颜色
  14. data() {
  15. return {
  16. i:0,
  17. datas: [{
  18. urls: '/pages/home/home',
  19. icon: '/static/menu/chat.png',
  20. actionIcon: '/static/menu/chat_s.png',
  21. name: '消息',
  22. id: 1,
  23. },
  24. {
  25. urls: '/pages/addressBook/addressBook',
  26. icon: '/static/menu/contact.png',
  27. actionIcon: '/static/menu/contact_s.png',
  28. name: '通讯录',
  29. id: 2,
  30. },
  31. {
  32. urls: '/pageC/find/find',
  33. icon: '/static/menu/see.png',
  34. actionIcon: '/static/menu/see_s.png',
  35. name: '发现',
  36. id: 3,
  37. },
  38. {
  39. urls: '/pageC/my/index',
  40. icon: '/static/menu/my.png',
  41. actionIcon: '/static/menu/my_s.png',
  42. name: '我',
  43. id: 4,
  44. },
  45. ],
  46. }
  47. },
  48. created() {
  49. this.i=this.totarBer.id-1
  50. //用来控制是显示当前页面的tarBar图标变亮
  51. if(this.totarBer.id==2){
  52. this.$set(this.datas[1],'color',this.totarBer.color)
  53. }
  54. if(this.totarBer.id==1){
  55. this.$set(this.datas[0],'color',this.totarBer.color)
  56. }
  57. if(this.totarBer.id==3){
  58. this.$set(this.datas[2],'color',this.totarBer.color)
  59. }
  60. if(this.totarBer.id==4){
  61. this.$set(this.datas[3],'color',this.totarBer.color)
  62. }
  63. },
  64. methods: {
  65. tabClick(i,urls, id) {
  66. console.log(11111111)
  67. this.i=i
  68. // if(i==0){
  69. uni.switchTab({
  70. url: urls
  71. });
  72. // }else{
  73. // uni.reLaunch({
  74. // url: urls
  75. // });
  76. // }
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped>
  82. .tarbar {
  83. width: 100%;
  84. height: 96rpx;
  85. display: flex;
  86. justify-content: space-around;
  87. background-color: #FFFFFF;
  88. position: fixed;
  89. bottom: 0;
  90. z-index: 100;
  91. font-size: 26rpx;
  92. color: #999999;
  93. }
  94. .tarbar view {
  95. text-align: center;
  96. }
  97. </style>