Vue底部导航栏组件如何改写为支持长尾词的智能交互式?
- 内容介绍
- 文章标签
- 相关推荐
本文共计424个文字,预计阅读时间需要2分钟。
不直接说代码,简要改写以下内容:
简单描述BottomNav.vue组件:底部导航栏,包含模板div,具有footer类,使用v-for遍历items数组。每个项根据索引改变类名,并绑定点击事件跳转路由。图标和文字颜色根据选中状态变化。
不多说直接上代码 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底部导航栏详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对自由互联网站的支持!
本文共计424个文字,预计阅读时间需要2分钟。
不直接说代码,简要改写以下内容:
简单描述BottomNav.vue组件:底部导航栏,包含模板div,具有footer类,使用v-for遍历items数组。每个项根据索引改变类名,并绑定点击事件跳转路由。图标和文字颜色根据选中状态变化。
不多说直接上代码 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底部导航栏详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对自由互联网站的支持!

