移动端如何让某些页面存在底部导航,某些页面不存在

1、新建bottomBar.vue,底部页面

<template>
  <div class="buttom_nav">
    <div class="nav-list">
      <mt-tabbar v-model="select">
        <mt-tab-item id="btnOne" @click.native="changeOne()">
            <img :src="btnUrl">
            <span>首页</span>
        </mt-tab-item>
        <mt-tab-item id="btnTwo" @click.native="changeTwo()">
            <van-icon name="notes-o" />
            <span> 项目</span>
        </mt-tab-item>
        <mt-tab-item id="btnThree" @click.native="changeThree()">
            <van-icon name="add-o" />
            <span> 发布</span>
        </mt-tab-item>
        <mt-tab-item id="btnFour" @click.native="changeFour()">
            <van-icon name="service-o" />
            <span>客服</span>
        </mt-tab-item>
        <mt-tab-item id="btnFive" @click.native="changeFive()">
            <van-icon name="user-circle-o" />
            <span>我的</span>
        </mt-tab-item>
      </mt-tabbar>
    </div>
  </div>
</template>

2、在App.vue中引入bottomBar.vue

<template>
  <div id="app">
    <router-view></router-view>
    <bottom-bar v-if="$route.meta.TabbarShow"></bottom-bar>
  </div>
</template>
<script>
import bottomBar from './components/bottomBar'
export default {
  name: 'App',
  components:{
    bottomBar
  }
}
</script>

3、用true和false去判断是否隐藏底部组件

<bottom-bar v-if="$route.meta.TabbarShow"></bottom-bar>

4、在router中设置TabbarShow为true或false

export default new Router({
  routes: [
    {
      path:'/',
      name:home,
      component:home,
      meta:{
        TabbarShow: true // 需要显示 底部导航
      }
    },
    {
      path:'/project',
      name:project,
      component:project,
      meta:{
        TabbarShow: true // 需要显示 底部导航
      }
    },
    {
      path:'/send',
      name:send,
      component:send,
      meta:{
        TabbarShow: true // 需要显示 底部导航
      }
    },
    {
      path:'/customer',
      name:customer,
      component:customer,
      meta:{
        TabbarShow: true // 需要显示 底部导航
      }
    },
    {
      path:'/my',
      name:my,
      component:my,
      meta:{
        TabbarShow: false // 需要显示 底部导航
      }
    }
  ]
})
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值