在配置路由实例时:
let router = new VueRouter({
routes: [ {
path: '/home',//配置路由
component: () =>
import ('../components/home'),//按需引入
meta: {
showTabBar: true//在路由meta对象设置一个布尔值showTabBar
}
}, {
path: '/callme',
component: () =>
import ('../components/callme'),
meta: {
showTabBar: false
}
}]
})
然后在tabbar标签使用v-if来实现显示和隐藏
<template>
<div class='app'>
<div class="tab-bar" v-if="$route.meta.showTabBar">
<ul>
<router-link tag="li" to="/home">首页</router-link>
<router-link tag="li" to="/callme">联系我们</router-link>
</ul>
</div>
<router-view></router-view>
</div>
</template>
这样在路由配置showTabBar的布尔值就可以来控制tabbar的显示和隐藏。