電商項(xiàng)目底部導(dǎo)航欄

html頁面
<template>
<div>
<router-view></router-view>
<div class="buttom-nav">
<ul :class="{nav:true, home:true, active:homeActive}" @click="goPage('/index')">
<li></li>
<li>首頁</li>
</ul>
<ul :class="{nav:true,cart:true, active:cartActive}" @click="goPage('/cart')">
<li></li>
<li>購物車</li>
<li class="spot"></li>
</ul>
<ul :class="{nav:true,my: true,active:myActive}" @click="goPage('/my')">
<li></li>
<li>我的</li>
</ul>
</div>
</div>
</template>

<script>
export default {
name: "home",
data(){
return {
homeActive:true,
cartActive:false,
myActive:false,
}
},
created(){
this.changeStyle(this.route.path) }, methods:{ goPage(url){ this.router.replace(url)
this.changeStyle(url)
},
changeStyle(url){
console.log(this.$route)
switch (url) {
case '/index':
this.homeActive=true
this.cartActive=false
this. myActive=false
break;

                case '/cart':
                    this.homeActive=false
                    this.cartActive=true
                    this. myActive=false
                    break

                case '/my':
                    this.homeActive=false
                    this.cartActive=false
                    this. myActive=true
                    break;

                default:
                    this.homeActive=true
                    this.cartActive=false
                    this. myActive=false
            }
        }
    }
}

</script>
// 樣式
<style scoped>
.buttom-nav{
width: 100%;
height:1.2rem;
background-color: #ffffff;
border-top:1px solid #cccccc;
position: fixed;
left:0;
bottom: 0;
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 0.7rem;
padding-right: 0.7rem;
box-sizing: border-box;
}
.buttom-nav .nav{
width: 0.9rem;
position: relative;
}
.buttom-nav .nav li:nth-child(1){
width: 0.6rem;
height: 0.6rem;
margin: 0 auto;
}
.buttom-nav .nav.active li:nth-child(2){
color:#ff0000;

}
.buttom-nav .nav li:nth-child(2){
    width: 100%;
    text-align: center;
    font-size: 0.28rem;
}
.buttom-nav .nav.home li:nth-child(1){
     background-image:url("../../../assets/images/common/home1.png") ;
     background-size:100% ;
     background-position: center;
 }
.buttom-nav .nav.home.active li:nth-child(1){
    background-image:url("../../../assets/images/common/home2.png") ;
    background-size:100% ;
    background-position: center;
}

.buttom-nav .nav.cart li:nth-child(1){
    background-image:url("../../../assets/images/common/cart1.png") ;
    background-size:100% ;
    background-position: center;
}
.buttom-nav .nav.cart.active li:nth-child(1){
    background-image:url("../../../assets/images/common/cart2.png") ;
    background-size:100% ;
    background-position: center;
}

.buttom-nav .nav .spot{
    width:0.2rem ;
    height:0.2rem ;
    background-color: red;
    border-radius: 100%;
    position:absolute;
    right: 0;
    top: 0;
}

.buttom-nav .nav.my li:nth-child(1){
    background-image:url("../../../assets/images/common/my1.png") ;
    background-size:100% ;
    background-position: center;
}
.buttom-nav .nav.my.active li:nth-child(1){
    background-image:url("../../../assets/images/common/my2.png") ;
    background-size:100% ;
    background-position: center;
}

</style>

//配置路由 router.js
import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

import IndexPage from './pages/home/main/index'
import HomeIndex from './pages/home/index/index'
import cartIndex from './pages/home/cart/index'
import myIndex from './pages/user/my/index'

export default new Router({
mode:"hash", //1纽门、hash哈希:有#號饶辙。2登钥、history歷史:沒有#號
base:process.env.BASE_URL, //自動獲取根目錄路徑
routes:[
{
path:"/",
name:"home",
component:IndexPage,
children:[
{
path:"index",
name:"index",
component:HomeIndex
},
{
path:"cart",
name:"cart",
component:cartIndex
},
{
path:"my",
name:"my",
component:myIndex
},
]
},

]

})

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末兰迫,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子潭兽,更是在濱河造成了極大的恐慌褒侧,老刑警劉巖驰坊,帶你破解...
    沈念sama閱讀 219,270評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異窑多,居然都是意外死亡仍稀,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,489評論 3 395
  • 文/潘曉璐 我一進(jìn)店門埂息,熙熙樓的掌柜王于貴愁眉苦臉地迎上來技潘,“玉大人遥巴,你說我怎么就攤上這事≌复郏” “怎么了挪哄?”我有些...
    開封第一講書人閱讀 165,630評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長琉闪。 經(jīng)常有香客問我迹炼,道長,這世上最難降的妖魔是什么颠毙? 我笑而不...
    開封第一講書人閱讀 58,906評論 1 295
  • 正文 為了忘掉前任斯入,我火速辦了婚禮,結(jié)果婚禮上蛀蜜,老公的妹妹穿的比我還像新娘刻两。我一直安慰自己,他們只是感情好滴某,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,928評論 6 392
  • 文/花漫 我一把揭開白布磅摹。 她就那樣靜靜地躺著,像睡著了一般霎奢。 火紅的嫁衣襯著肌膚如雪户誓。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,718評論 1 305
  • 那天幕侠,我揣著相機(jī)與錄音帝美,去河邊找鬼。 笑死晤硕,一個(gè)胖子當(dāng)著我的面吹牛悼潭,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播舞箍,決...
    沈念sama閱讀 40,442評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼舰褪,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了疏橄?” 一聲冷哼從身側(cè)響起抵知,我...
    開封第一講書人閱讀 39,345評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎软族,沒想到半個(gè)月后刷喜,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,802評論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡立砸,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,984評論 3 337
  • 正文 我和宋清朗相戀三年掖疮,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片颗祝。...
    茶點(diǎn)故事閱讀 40,117評論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡浊闪,死狀恐怖恼布,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情搁宾,我是刑警寧澤折汞,帶...
    沈念sama閱讀 35,810評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站盖腿,受9級特大地震影響爽待,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜翩腐,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,462評論 3 331
  • 文/蒙蒙 一鸟款、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧茂卦,春花似錦何什、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,011評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至蛛砰,卻和暖如春霍比,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背暴备。 一陣腳步聲響...
    開封第一講書人閱讀 33,139評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留们豌,地道東北人涯捻。 一個(gè)月前我還...
    沈念sama閱讀 48,377評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像望迎,于是被迫代替她去往敵國和親障癌。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,060評論 2 355

推薦閱讀更多精彩內(nèi)容