vue里面的底部菜单

<template>
    <div class="mui-row">
        <div class="mui-col-xs-12 mui-row nav">
            <div class="mui-col-xs-4" @tap="tab1=1;tab2=1;tab3=1">
                <router-link to="/recommend" ><img :src="'img/tabIcon/tab1'+tab1+'.png'" @tap="tab1=1;tab2=1;tab3=1"/><span class="mui-tab-label"  @tap="tab1=1;tab2=1;tab3=1">{{"推荐好课" | title}}</span></router-link>
            </div>
            <div class="mui-col-xs-4" @tap="tab2=2;tab1=2;tab3=1">
                <router-link :to="{path: '/Broadcast/' +(tabNum=tabNum==undefined?0:tabNum)}"><img :src="'img/tabIcon/tab2'+tab2+'.png'" @tap="tab2=2;tab1=2;tab3=1"/><span class="mui-tab-label"  @tap="tab2=2;tab1=2;tab3=1">{{"师道直播" | title}}</span></router-link>
            </div>
            <div class="mui-col-xs-4" @tap="tab3=2;tab1=2;tab2=1">
                <router-link to="/my"><img :src="'img/tabIcon/tab3'+tab3+'.png'" @tap="tab3=2;tab1=2;tab2=1"/><span class="mui-tab-label"  @tap="tab3=2;tab1=2;tab2=1">{{"我" | title}}</span></router-link>
            </div>
        </div>
    </div> 
    
</template>
<style scoped>
    .mui-row { background: #FFF; border-top:1px solid #F5F5F5; }
    .mui-col-xs-12 .mui-col-xs-4 { text-align: center; height: 50px; }
    img{position:relative; top:0px; width: 30px; height: 30px; padding-top: 0; padding-bottom: 0; }
    .mui-tab-label{ font-size: 11px; display: block; overflow: hidden; text-overflow: ellipsis; margin-top: -7px; }
    a{color:#b9b5b5;}
    .mui-bar{ -webkit-box-shadow: 0 0 1px rgba(222, 219, 219, 0.85); box-shadow: 0 0 1px rgba(222, 219, 219, 0.85); }
    .mui-row .router-link-exact-active.router-link-active{ color:#3FCDFF; } 
    .mui-col-xs-12 .mui-col-xs-4 a{height: 50px; display: inline-block; width: 100%;}
</style>
<script>
 export default {
        created() {
         this.$route.params.tabNum=0;
        },
        mounted() {
        if(this.$route.params.tabNum!='undefined'){
		       this.tabNum=this.$route.params.tabNum;//因为这个切换选项卡就path改变了
            }
        	else{
        		this.tabNum=0;	
        	}	

         if(this.$route.path=='/my'){
         	this.tab3=2;this.tab1=2;this.tab2=1
         }
         else if(this.$route.path=='/Broadcast/'+this.tabNum){//因为这里的path是随着选项卡切换改变的。所以要写成动态的。
         	this.tab2=2;this.tab1=2;this.tab3=1
         }else{
         	this.tab1=1;this.tab2=1;this.tab3=1
         }
     	 
        },
        beforeRouteEnter(to, from, next) {
        //	console.log(to)
        //     if (to.params.db == null) {
        //         return next({ name: "", params: { id: to.params.id } });
        //     }
        //     next();
           },
        components: {},
        data() {
            return {
               tabNum:0,
               tab1:1,
               tab2:1,
               tab3:1,
            }
        },

        methods: {
     
        },
        watch:{
        	 "$route.params"(tab){ //
			       this.tabNum=this.$route.params.tabNum;
            },
             
        	}
    }
</script>

我的几个图标是这样的。

最终的效果点击那个那个就变成蓝色的。并且进入子页面再切出来他还是蓝色的。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值