Vue实现导航栏点击当前标签变色功能
2019-05-28 07:01
1766 查看
本文实例为大家分享了Vue实现导航栏点击当前标签变色功能的具体代码,供大家参考,具体内容如下
1.效果
2.所有代码
<template> <div class="now-time"> <div class="timebox"> <a href="#" rel="external nofollow" v-for="(item,index) in nowTime" v-on:click="addClass(index)" v-bind:class="{ bgColors:index==current}"> <p>{{item.time}}</p> <p>{{item.start}}</p> </a> </div> </div> </template> <script> export default { name: "Nowtime", methods: { addClass:function(index){ this.current=index; } }, mounted() { }, data(){ return{ current:0, nowTime:[ { time:"9:00", start:"已开抢" }, { time:"10:00", start:"已开抢" }, { time:"11:00", start:"已开抢" }, { time:"12:00", start:"已开抢" }, { time:"13:00", start:"未开抢" }, { time:"14:00", start:"未开抢" }, { time:"15:00", start:"未开抢" }, ], } } } </script> <style scoped> .now-time{ width: 100%; height: .8rem; background: #282832; display: flex; overflow-x:scroll; } .timebox{ width: 100%; height: .8rem; display: flex; background: #282832; } .now-time a{ display: flex; flex-direction: column; width: 1.35rem; height: .79rem; align-items: center; flex-shrink: 0; } .now-time a p:first-child{ font-size: .23rem; color: white; font-weight: bold; } .now-time a p:last-child{ font-size: .16rem; color: white; } .timebox .bgColors{ background: #ff5700; } </style>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- JS实现导航栏记住点击后的浏览位置变色功能
- Js实现当前点击a标签变色,其他a标签回复原色
- vue实现点击当前标签高亮效果
- vue实现点击当前标签高亮效果【推荐】
- Js实现当前点击a标签变色突出显示其他a标签回复原色
- Js实现当前点击a标签变色突出显示其他a标签回复原色
- 统计报表中嵌入<a>标签,点击实现弹出清单功能
- 微信小程序实现点击按钮移动view标签的位置功能示例【附demo源码下载】
- jQuery代码实现表格中点击相应行变色功能
- 微信小程序实现点击按钮修改view标签背景颜色功能示例【附demo源码下载】
- vue-router 如何在当前路由下重新点击当前路由的router-link实现刷新 组件重新渲染
- vue数据操作之点击事件实现num加减功能示例
- JS实现的简单标签点击切换功能示例
- vue实现文章内容过长点击阅读全文功能
- vue实现a标签点击高亮
- a标签怎么去下划线以及实现点击前和点击后不变色
- Vue实现点击后文字变色切换方法
- jquery实现表格中点击相应行变色功能
- vue使用ElementUI时导航栏默认展开功能的实现
- jquery实现表格中点击相应行变色功能