Vue實(shí)現(xiàn)導(dǎo)航欄點(diǎn)擊當(dāng)前標(biāo)簽變色功能
本文實(shí)例為大家分享了Vue實(shí)現(xiàn)導(dǎo)航欄點(diǎn)擊當(dāng)前標(biāo)簽變色功能的具體代碼,供大家參考,具體內(nèi)容如下
1.效果

2.所有代碼
<template>
<div class="now-time">
<div class="timebox">
<a href="#" 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:"已開(kāi)搶"
},
{
time:"10:00",
start:"已開(kāi)搶"
},
{
time:"11:00",
start:"已開(kāi)搶"
},
{
time:"12:00",
start:"已開(kāi)搶"
},
{
time:"13:00",
start:"未開(kāi)搶"
},
{
time:"14:00",
start:"未開(kāi)搶"
},
{
time:"15:00",
start:"未開(kāi)搶"
},
],
}
}
}
</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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Vue3點(diǎn)擊側(cè)邊導(dǎo)航欄完成切換頁(yè)面內(nèi)組件全過(guò)程(WEB)
- Vue實(shí)現(xiàn)點(diǎn)擊導(dǎo)航欄當(dāng)前標(biāo)簽后變色功能
- vue 導(dǎo)航錨點(diǎn)_點(diǎn)擊平滑滾動(dòng),導(dǎo)航欄對(duì)應(yīng)變化詳解
- Vue滾動(dòng)到指定位置的多種方式示例詳解
- Vue滾動(dòng)頁(yè)面到指定位置的實(shí)現(xiàn)及避坑
- vue實(shí)現(xiàn)滾動(dòng)條到頂部或者到指定位置
- vue實(shí)現(xiàn)點(diǎn)擊導(dǎo)航欄滾動(dòng)頁(yè)面到指定位置的功能(推薦)
相關(guān)文章
vue中導(dǎo)出Excel表格的實(shí)現(xiàn)代碼
項(xiàng)目中我們可能會(huì)碰到導(dǎo)出Excel文件的需求,這篇文章主要介紹了vue中導(dǎo)出Excel表格的實(shí)現(xiàn)代碼,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2018-10-10
詳解element-ui表格的合并行和列(非常細(xì)節(jié))
最近在需求中遇到了elementUI合并行,索性給大家整理下,這篇文章主要給大家介紹了關(guān)于element-ui表格的合并行和列的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-06-06
vue使用lottie-web實(shí)現(xiàn)web動(dòng)畫(huà)效果
在web端,lottie-web庫(kù)可以解析導(dǎo)出的動(dòng)畫(huà)json文件,并將其以svg或者canvas的方式將動(dòng)畫(huà)繪制在我們的頁(yè)面上,這篇文章主要介紹了vue使用lottie-web實(shí)現(xiàn)web動(dòng)畫(huà),需要的朋友可以參考下2024-06-06
解決vue+elementui項(xiàng)目打包后樣式變化問(wèn)題
這篇文章主要介紹了解決vue+elementui項(xiàng)目打包后樣式變化問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-08-08
vue原理Compile從新建實(shí)例到結(jié)束流程源碼
這篇文章主要為大家介紹了vue原理Compile從新建實(shí)例到結(jié)束流程源碼,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07
Vue實(shí)現(xiàn)手機(jī)號(hào)、驗(yàn)證碼登錄(60s禁用倒計(jì)時(shí))
這篇文章主要介紹了Vue實(shí)現(xiàn)手機(jī)號(hào)、驗(yàn)證碼登錄(60s禁用倒計(jì)時(shí)),幫助大家更好的理解和使用vue,感興趣的朋友可以了解下2020-12-12
vue+three.js實(shí)現(xiàn)炫酷的3D登陸頁(yè)面示例詳解
這篇文章主要為大家介紹了vue+three.js實(shí)現(xiàn)炫酷的3D登陸頁(yè)面示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07

