效果展示
我的代码
<template>
<div class="nav-container">
<!-- 动态底部导航栏 start-->
<div class="nav-content">
<van-tabbar style="background-image: linear-gradient(135deg, #EE9AE5 10%, #5961F9 100%) !important;"
v-model="active">
<van-tabbar-item v-for="(icon,index) in icons.list" :key="index" :to="icon.path">
<span>{{ icon.name }}</span>
<template #icon="props">
<img :src="props.active ? icon.active : icon.inactive"/>
</template>
</van-tabbar-item>
</van-tabbar>
</div>
<!-- 动态底部导航栏 end-->
</div>
</template>
<script setup>
import {reactive, ref} from "vue";
const active = ref(0);
const icons = reactive({
list: [
{
path:'/',
name: '首页',
inactive: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAgdJREFUWEftlk1LG1EUht8zKUJddCG4qIXuCkJru1TajaIzyR3bZT+Q/gMVMROVrura5saC+g/6QXXZOjeZCHUhaJfVtrgUEQrtrpuCkDliAzbRmclMhiEIubvL+XrOC/fcQ2jxoRbXx+UEmB5Z79OIHoG0x/8UZHfNZf64uDG6F1XRyApkjfWHGlIrDL5ZW4xAhy4q4wVn9FMUiEgAWb04TsTLQQWYaaJQzqyEhQgNYBlqAcBMyMSvpCNmw/iGArB09QGEJ2ESnvkwVmVZPG0U0xDAMuwdgPobJfK28xfpmANBsb4Ak8K+1lGhfQDXmyt+FvXzOMW9S8r845XHEyBnlO4w3MhPKrhTrS/vpL+d97kAMKPbD1yirZhde4en+LZU5o/651tzeyHs7uMK/UqkeDXptnTEfV+A3IgaZA2fEwSAdESd6nWXNkBbgbYCl0mB72D8rpsXhC4w3wLR1aA5En8OEC/IkjnnVcQy1HsAzxIFIBdD+Q2x6VUka6iXBMw3DTA1rO5eSeFr4K8WB4D5ryybnb5/wanB0u0jEN3wg4ipwK50xL1AgKxeXCLiiSQAmGm5UM5MBgKcGnNptcqM6s5/7jSrABHW8iVxYa/0Xcly6eIYM54DLGoYDioahl4XxYEXXHWO0FuAe/7bSRHhTb6UeefZUJJ/f5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+0bC9I9dm0QnoNgcmQHZWnQ+ZB0VeeqOOrsIXKqGgT0qgF8RJAMcqgdH+KUNkQQUf+6J2f7Gz/wDdFRpuUYmTKAAAAABJRU5ErkJggg==',
},
{
path:'/home/find',
name: '发现',
active: 'http://jkw.life:8020/icon/分类-01.png',
inactive: 'http://jkw.life:8020/icon/分类-01-01.png',
},
{
path:'/home/find',
name: '资讯',
active: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAA1BJREFUWEftV0t200AQrB6TDytyA8INcgPMIn4WLDAnsDmBBQnrOGviPPkEyCfAWYCCs8DcIEewb+Cs8kPTvBlL8kiZkZy8ZId29mhmSt3V1dW034h6DBwANCLBg6NTb4InfPYaP1uAaAPcIuCQ9hoRF+6bgimIby+HweTD/DGw+PXvW7W1520Q+wC2zTNtAJbrhFBIOfh69u78IUC+7P7YkUJ0wei49mcAGDghQH1xC8CL/AY6Bzjoj73hKkA+70YdIuoCvFN4/wLAiIEtAt6rtQyAysfR2OupcIm1zZYgdBh4XQAyZyCUggfBqTc11/xmtC0kdQnqa3krF2bgj2SE8vZqpNK65J0FQPHQZxIdViEkvMyBYUxIUMAsCUxdEOqF9RkRwr8CYRHsygDMA/ebUZ2lzqUlRdmbOsQkEJZV04MApFfYUkSFEFfxpBSAymVN4rc+pKIc9xuR1oyjsZcPf4JAg13fTHgBxAJvVDpKAZiLi3NozuBACgwtubQCcBEyJXp1BGJM7pBOY0EYEw5TIMUI6OgxDqx1z5jFNdQrI5DmT9cy0LMAmfbH3iv1XhHA3m40tVTLjIHe8ZkXpmffi4RKuwnkZ5rAmPXPPC2nZQAUMSHQs1VDJYCFkoHjm6uTtB8oWWUSLbOubSlQukEsR6l86z6wvqlVL1XSUgDJ5d9yBLy5GtgaU1kVLCuA/FQZmfFRpeIeAIyKLhDQlgL1XxkRVwKgDikhINJSsgG4W8LJBzByRKzkgFkJtqbUH3tkJWHBW6QKaVZAsi8x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3zJaNqPxHuVjVEGM3k5cB8KTQESAkVLKKuWjE9A+O+g5Keni5+Cmptbe2rfUQECHsB3jpnsM+ulqvCApRjbPWpTl89H1MC/zhAUqgvBCxvZQoY+OppuSLUGkgKdYuAgy0C3Pa0PBQKIN2vtrODx60AkI8dmTH5JBRAILI5/eYzr56KoU/CqjAZVQeIcBTAGgDLDIl8A/CRGde9grxjSs/6MjIZha3/B/gNNqzhIdHwUi8AAAAASUVORK5CYII=',
},
]
})
</script>
<style scoped>
.van-tabbar-item--active{
background: linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
background: -o-linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
background: -ms-linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
background: -moz-linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
background: -webkit-linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
}
</style>
vant4的Tabbar 标签栏的使用
基本使用案例
<van-tabbar v-model="active">
<van-tabbar-item icon="home-o">标签</van-tabbar-item>
<van-tabbar-item icon="search">标签</van-tabbar-item>
<van-tabbar-item icon="friends-o">标签</van-tabbar-item>
<van-tabbar-item icon="setting-o">标签</van-tabbar-item>
</van-tabbar>
自定义图标使用案例
用<template #icon="props">插槽结合动态数据绑定达到图标的自定义效果
<van-tabbar v-model="active">
<van-tabbar-item badge="3">
<span>自定义</span>
<template #icon="props">
<img :src="props.active ? icon.active : icon.inactive" />
</template>
</van-tabbar-item>
<van-tabbar-item icon="search">标签</van-tabbar-item>
<van-tabbar-item icon="setting-o">标签</van-tabbar-item>
</van-tabbar>
import { ref } from 'vue';
export default {
setup() {
const active = ref(0);
const icon = {
active: 'https://fastly.jsdelivr.net/npm/@vant/assets/user-active.png',
inactive:
'https://fastly.jsdelivr.net/npm/@vant/assets/user-inactive.png',
};
return {
icon,
active,
};
},
};
代码详解
自定义导航栏背景色
style="background-image: linear-gradient(135deg, #EE9AE5 10%, #5961F9 100%) !important;"
自定义导航栏选中部分颜色
<style scoped>
.van-tabbar-item--active{
background: linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
background: -o-linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
background: -ms-linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
background: -moz-linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
background: -webkit-linear-gradient(left , rgb(188, 123, 255) 23% , rgb(243, 168, 250) 81%);
}
</style>
绑定一个动态的active参数值
v-model="active"
import {reactive, ref} from "vue";
const active = ref(0);
动态数据的设定
path为路由跳转路径,name为底部描述文字,active为选中时的图标,inactive为未选中时的图标
const icons = reactive({
list: [
{
path:'/',
name: '首页',
inactive: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAgdJREFUWEftlk1LG1EUht8zKUJddCG4qIXuCkJru1TajaIzyR3bZT+Q/gMVMROVrura5saC+g/6QXXZOjeZCHUhaJfVtrgUEQrtrpuCkDliAzbRmclMhiEIubvL+XrOC/fcQ2jxoRbXx+UEmB5Z79OIHoG0x/8UZHfNZf64uDG6F1XRyApkjfWHGlIrDL5ZW4xAhy4q4wVn9FMUiEgAWb04TsTLQQWYaaJQzqyEhQgNYBlqAcBMyMSvpCNmw/iGArB09QGEJ2ESnvkwVmVZPG0U0xDAMuwdgPobJfK28xfpmANBsb4Ak8K+1lGhfQDXmyt+FvXzOMW9S8r845XHEyBnlO4w3MhPKrhTrS/vpL+d97kAMKPbD1yirZhde4en+LZU5o/651tzeyHs7uMK/UqkeDXptnTEfV+A3IgaZA2fEwSAdESd6nWXNkBbgbYCl0mB72D8rpsXhC4w3wLR1aA5En8OEC/IkjnnVcQy1HsAzxIFIBdD+Q2x6VUka6iXBMw3DTA1rO5eSeFr4K8WB4D5ryybnb5/wanB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b5LADti9safEuBTQBTVSDlAMg4BGn35wG4rKG7FHlSlbjuWSMjfcv9eQC91tDROsFXQA4BqDwZSwNotb+UIM6OhW0/0uWYe9v027CaOJfxQOZbsCjAVmeEsxCD1n6Ltd6SvxH+0bC9I9dm0QnoNgcmQHZWnQ+ZB0VeeqOOrsIXKqGgT0qgF8RJAMcqgdH+KUNkQQUf+6J2f7Gz/wDdFRpuUYmTKAAAAABJRU5ErkJggg==',
},
{
path:'/home/find',
name: '发现',
active: 'http://jkw.life:8020/icon/分类-01.png',
inactive: 'http://jkw.life:8020/icon/分类-01-01.png',
},
{
path:'/home/find',
name: '资讯',
active: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAA1BJREFUWEftV0t200AQrB6TDytyA8INcgPMIn4WLDAnsDmBBQnrOGviPPkEyCfAWYCCs8DcIEewb+Cs8kPTvBlL8kiZkZy8ZId29mhmSt3V1dW034h6DBwANCLBg6NTb4InfPYaP1uAaAPcIuCQ9hoRF+6bgimIby+HweTD/DGw+PXvW7W1520Q+wC2zTNtAJbrhFBIOfh69u78IUC+7P7YkUJ0wei49mcAGDghQH1xC8CL/AY6Bzjoj73hKkA+70YdIuoCvFN4/wLAiIEtAt6rtQyAysfR2OupcIm1zZYgdBh4XQAyZyCUggfBqTc11/xmtC0kdQnqa3krF2bgj2SE8vZqpNK65J0FQPHQZxIdViEkvMyBYUxIUMAsCUxdEOqF9RkRwr8CYRHsygDMA/ebUZ2lzqUlRdmbOsQkEJZV04MApFfYUkSFEFfxpBSAymVN4rc+pKIc9xuR1oyjsZcPf4JAg13fTHgBxAJvVDpKAZiLi3NozuBACgwtubQCcBEyJXp1BGJM7pBOY0EYEw5TIMUI6OgxDqx1z5jFNdQrI5DmT9cy0LMAmfbH3iv1XhHA3m40tVTLjIHe8ZkXpmffi4RKuwnkZ5rAmPXPPC2nZQAUMSHQs1VDJYCFkoHjm6uTtB8oWWUSLbOubSlQ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GJ34/+OmKkpF0AYA/jQPz7M34yytqPr2zARkxoBU00ACqoel459Bwx7diUoQKcW2+s3YgVVISqt2lYIyMPCJ+c3YZqBKEGZzZbjE113wA+Arsp3AA67RYceLz4D81kwf94YsfbdWTj5NXSA1NFX21aGIt/twArzWKasvXVuULU4x+BLTkLGGaMsXriLadJ8QSTZqoRftIOv6UhdlTMAJuu5+WLO1B57ddIDYGECpDxqDNZpC9wAerxwF0zOUcxsXcuVTzxsFaMJ4Gp0futgZHgZ4J0A/QDzODG+tIfg/axQvl4t0o4AdYaPk0ZJM9r5esruhFo6QrCcffT12KLbFYnAN7OmdruTf0vdbx8oXFOuKMQjzNjcPhBtB6xd9arpOVl42epTrOMQdiIOez2UL59eoP4C7SmoMBnbuvgAAAAASUVORK5CYII=',
},
{
path:'/home/center',
name: '我的',
active: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAu9JREFUWEfFlU9IFGEYxp93DIVS6VQUFFR0yeimRIEFtrM7u0R1WCMhsPAiZMHMFmGhq0Ed3FkpI8gOBVLZeigJZnZnLdJDkJ2iDklgkWB/TqISJO28sUvrv3ZndmYXnMvAfO/zPL/v/Yb3I6zxQ2ucD8cAbZJWXW4KTQBLAA7828BrgPQFwXzUp/tnnWyqYIBgMFa2faayG0TtlgHM179unO8YGmpMFQJSEIAiJuoB8wGAHYWYAvgMCM2q4R2zq7cFCCMszIp1nwi0085s+TqDJ6uN8d1hhE0rnS2A4ol3gbjDSfhiLVO3mvR1ugZok7SK8hT9BFDtCgCYXSjjTX26/3c+vWUHZI/eTIT7LsMzMmaciSal9P+T87EEUDz6ExAaiwEAI6YmpZPuAER9GsCWogCAb6ohbXULMAegsjgAmlcNX5VLAG0UoPoiAcZUw3fIFYAs6p0EhIsBYCAcNaQuVwAhMbGXYb4vBsA0zX29I4G8HvaDSIw/Bfi4GwgGhqOGZKm1B/DptTAx7gaAYO6PGIE3ridhVqh4tA4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autMjvZJQWuTqhkkKdI2CokYSBIU/L8ymRlczU4RXkaOhdkBb5PoavAKx0tSyndTKWi/vMZwFaD3BHxZx+APzGIbpwJR/PBV9SQnHwZsZAI4iGU5AW6jIDp6p/MNesfEMCmH3zJaNqPxHuVjVEGM3k5cB8KTQESAkVLKKuWjE9A+O+g5Keni5+Cmptbe2rfUQECHsB3jpnsM+ulqvCApRjbPWpTl89H1MC/zhAUqgvBCxvZQoY+OppuSLUGkgKdYuAgy0C3Pa0PBQKIN2vtrODx60AkI8dmTH5JBRAILI5/eYzr56KoU/CqjAZVQeIcBTAGgDLDIl8A/CRGde9grxjSs/6MjIZha3/B/gNNqzhIdHwUi8AAAAASUVORK5CYII=',
},
]
})
动态数据的绑定 以及遍历
<van-tabbar-item v-for="(icon,index) in icons.list" :key="index" :to="icon.path">
<span>{{ icon.name }}</span>
<template #icon="props">
<img :src="props.active ? icon.active : icon.inactive"/>
</template>
</van-tabbar-item>
icon图标的寻找
网址
阿里巴巴矢量库
首先搜索想要的图标
点击下载图标 (实际不用下载,这步是为了拿到图标的网址)