需要更换图片样式自行更改
投的页面不需要底部导航栏在 在路由原信息里面设置true或false 在使用组件是进行显示和隐藏
<template>
<div class="footbar-main">
<ul class="bootbar">
<router-link class="bootbar-item" :to="{name: 'home'}" tag="li">
<span class="footbar-img home"></span>
<span class="footbar-text">首页</span>
</router-link>
<router-link class="bootbar-item" :to="{name: 'kind'}" tag="li">
<span class="footbar-img kind"></span>
<span class="footbar-text">分类</span>
</router-link>
<router-link class="bootbar-item" :to="{name: 'find'}" tag="li">
<span class="footbar-img find"></span>
<span class="footbar-text">发现</span>
</router-link>
<router-link class="bootbar-item" :to="{name: 'mine'}" tag="li">
<span class="footbar-img mine"></span>
<span class="footbar-text">我的</span>
</router-link>
</ul>
</div>
</template>
<script>
export default {
name: 'Footbar',
data() {
return {
}
}
}
</script>
<style lang="scss" scoped>
.footbar-main {
position: fixed;
left: 0;
bottom: 0;
height: 80px;
width: 100%;
background-color: #fff;
z-index: 999;
.bootbar {
display: flex;
height: 100%;
width: 100%;
padding: 15px;
box-sizing: border-box;
.bootbar-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 25%;
height: 100%;
.footbar-img {
// 背景图片公共
height: 40px;
width: 40px;
background-size: 80%;
background-position: center;
background-repeat: no-repeat;
//当前展示图片
&.home {
background-image: url("../../assets/imgs/icons/home.png");
}
&.kind {
background-image: url("../../assets/imgs/icons/kind.png");
}
&.find {
background-image: url("../../assets/imgs/icons/find.png");
}
&.mine {
background-image: url("../../assets/imgs/icons/mine.png");
}
}
// 当前激活路由图片
&.router-link-active {
.footbar-text{
color: #1C4B47;
}
.footbar-img.home {
background-image: url("../../assets/imgs/icons/home-active.png");
}
.footbar-img.kind {
background-image: url("../../assets/imgs/icons/kind-active.png");
}
.footbar-img.find {
background-image: url("../../assets/imgs/icons/find-active.png");
}
.footbar-img.mine {
background-image: url("../../assets/imgs/icons/mine-active.png");
}
}
.footbar-text {
padding-top: 5px;
font-size: 12px;
color: #8e8e93;
}
}
}
}
</style>
```