在vue项目中,不管我们跳到哪个页面,tabbar导航一直都在,但是有些时候我们的子页面是不需要tabbar导航的,所以这个时候我们就需要去掉这个tabbar导航了。
在router的index.js中使用路由的钩子函数beforeEach来解决。
router.beforeEach((to, from, next)=>{
if(to.path.startsWith('/sosuo')||to.path.startsWith('/ssxq')){
setTimeout(function () {
let tab=document.getElementsByClassName('mint-tabbar')[0]
tab.style.display='none'
},100)
next()
}else{
setTimeout(function () {
let tab=document.getElementsByClassName('mint-tabbar')[0]
tab.style.display=''
},100)
next()
}
})