dacizi-navtag.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="nav_tab">
  3. <view class="buttom_height"></view>
  4. <view class="tab_button">
  5. <view class="tab_item" v-for="(item,index) in tab_button" :key='index' :data-current="index" @tap="switchTab(index)">
  6. <image :src="item_index == index ? item.light_icon : item.default_icon" ></image>
  7. <view :class="item_index == index ? 'active_item': ''">{{item.itemText}}</view>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. props:{
  15. current:{ // 当前页面index
  16. type:Number,
  17. default:0
  18. },
  19. },
  20. data() {
  21. return {
  22. tab_button:[
  23. {itemText:"首页",default_icon:"/static/n_d1.png",light_icon:"/static/n_l1.png",path:"/pages/index/index"},
  24. {itemText:"我的",default_icon:"/static/n_d2.png",light_icon:"/static/n_l2.png",path:"/pages/mine/mine"},
  25. ],
  26. item_index: this.current
  27. }
  28. },
  29. onShow() {
  30. },
  31. methods: {
  32. switchTab:function(index){
  33. this.item_index = index
  34. uni.reLaunch({
  35. url:this.tab_button[index].path
  36. })
  37. this.$emit('click', index)
  38. console.info("index...链接",index,this.item_index)
  39. },
  40. },
  41. }
  42. </script>
  43. <style lang="scss">
  44. .buttom_height{
  45. height: 100rpx;
  46. }
  47. .tab_button{
  48. width: 100%;
  49. position: fixed;
  50. z-index: 1;
  51. bottom: 0rpx;
  52. display: flex;
  53. height: 100rpx;
  54. text-align: center;
  55. background-color: #FFFFFF;
  56. box-shadow: 0rpx 4rpx 8rpx 0rpx;
  57. padding-bottom: constant(safe-area-inset-bottom);
  58. padding-bottom: env(safe-area-inset-bottom);
  59. .tab_item{
  60. margin-top: 10rpx;
  61. width: 50%;
  62. font-size: 24rpx;
  63. color: #666666;
  64. image{
  65. width: 48rpx;
  66. height: 48rpx;
  67. }
  68. .active_item{
  69. color: #d81e06;
  70. }
  71. }
  72. }
  73. </style>