不多说直接上代码 bottomnav.vue:
<template> <div class="footer"> <div v-for='(item,index) of items' :class='[item.cls,{on:index === idx}]' @click="$router.push(item.push)"> <img :src="index===idx?item.iconselect:item.icon"> <p :class="['colorchange',{on:index===idx}]" >{{item.name}}</p> </div> </div> </template> <script type="text/javascript"> export default{ props:['idx'], data(){ return { items:[{ cls:"home", name:"首页", push:"/home", icon:"../static/home.png", iconselect:"../static/home_select.png" }, { cls:"shares", name:"股票", push:"/shares", icon:"../static/home.png", iconselect:"../static/home_select.png" }, { cla:"community", name:"社区", push:"/community", icon:"../static/home.png", iconselect:"../static/home_select.png" }, { cla:"mine", name:"我的", push:"/mine", icon:"../static/home.png", iconselect:"../static/home_select.png" }] } } } </script>
:src="index===idx?item.iconselect:item.icon" 通过代码判断是否是当前页面,选择不通的图片
@click="$router.push(item.push) 跳转到各个页面
style:
.footer{ display: flex; position: absolute; left: 0; bottom: 0; box-sizing: border-box; height: 6rem; background: #909090; width: 100%;} div{ flex: 1; font-size: 30px; } div img{ width: 30px; height: 30px; } div p{ color:black; } .on{ color: red; }
使用方式:
导入:
<bnai :idx="0"> </bnai>
以上所述是小编给大家介绍的vue底部导航栏详解整合,希望对大家有所帮助
如对本文有疑问, 点击进行留言回复!!
将uniapp打包成h5放在安卓webview中(解决uniapp引入第三方地图卡顿问题)
Vue项目判断 是移动端还是PC , 微信 , iOS , 安卓
vue用elementui写form表单时,在label里添加空格操作
解决vue net :ERR_CONNECTION_REFUSED报错问题
vue devtools怎么安装?浏览器vue调试插件vue.js devtools安装及使用教程
网友评论