最近vue不是特别火,自己想写一个vue 的底部菜单栏,然后试着开始写,起来还是听痛苦的,但是还是写出来,这个过程重查询了一些资料和看了一些视频。
1 写好界面
这是我写好的四个界面
2 在router.js重定义路由
在一级路由下面定义自己tabbr的子路由。
routes: [
{
path: '/',
name: 'index',
component:()=>import('./views/index'), //懒加载引入,路由
children:[
{path:'',redirect:'/charts'},//重定项
{path:'/charts',name:'charts',component:()=>import('./views/charts.vue')},
{path:'/adiscover',name:'adiscover',component:()=>import('./views/adiscover.vue')},
{path:'/ybutton',ybutton:'ybutton',component:()=>import('./views/ybutton.vue')},
{path:'/me',name:'me',component:()=>import('./views/me.vue')}
]
},
]
3 封装tabbar底部菜单栏 组件
1
{{item.title}}
.footer{
position: fixed;
bottom:0px;
left:0px;
width:100%;
display:flex;
justify-content: space-between;
}
.footer .divs{padding:10px;}
.red{color:red;font-size:14px;}
.bloack{font-size:14px;color:black;}
.footbar{
width: 100%;
height: 2.613333rem;
position: fixed;
bottom: 0;
display: flex;
align-items: center;
background: white;
border-top: 1px solid #eeeeee;
color: #999999;
}
.footbar span{
display: block;
font-size: .64rem;
}
.footbar div{
flex: 1;
text-align: center;
}
.footbar img{
height: 1.066667rem;
}
.footbar .router-link-exact-active{
color: #2F83C3;
}
.footbar .active{
color: #2F83C3;
}
4 显示底部菜单栏的界面 引入tabbar 组件
主页
.index{
width:100%;
height:100%;
overflow: hidden;
padding:16px;
box-sizing:border-box;
}
5 这就是最终结果
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



