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 // 需要显示 底部导航
}
}
]
})