欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue如何實(shí)現(xiàn)自定義底部菜單欄

 更新時間:2019年07月01日 14:30:02   作者:小李不小  
這篇文章主要介紹了vue如何實(shí)現(xiàn)自定義底部菜單欄,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下

最近vue不是特別火,自己想寫一個vue 的底部菜單欄,然后試著開始寫,起來還是聽痛苦的,但是還是寫出來,這個過程重查詢了一些資料和看了一些視頻。

1 寫好界面

這是我寫好的四個界面

2 在router.js重定義路由

在一級路由下面定義自己tabbr的子路由。

routes: [
  {
   path: '/',
   name: 'index',
   component:()=>import('./views/index'), //懶加載引入,路由
   children:[
    {path:'',redirect:'/charts'},//重定項
    {path:'/charts',name:'charts',component:()=>import('./views/charts.vue')},
    {path:'/adiscover',name:'adiscover',component:()=>import('./views/adiscover.vue')},
    {path:'/ybutton',ybutton:'ybutton',component:()=>import('./views/ybutton.vue')},
    {path:'/me',name:'me',component:()=>import('./views/me.vue')}
   ]
  },
]

3 封裝tabbar底部菜單欄 組件

<template>
<!-- <div class="footbar">
   <router-link to='/' tag='div'>
     <span>      <img :src="this.$route.path=='/charts'?'https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=3100024767,29226190&fm=58':'https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=3993527673,913427098&fm=58'" alt="">
     </span>
     <span>資產(chǎn)</span>
   </router-link>
   <router-link to='/adiscover' tag='div'>
     <span>      <img :src="this.$route.path=='/adiscover'?'https://10.url.cn/qqcourse_logo_ng/ajNVdqHZLLAcYPom22osQf2IIdMD25ofYUibd1USSQFHdiaUIiavicpAibgSReIqCky8gqY8ku5qdXsc/356':'https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=3993527673,913427098&fm=58'" alt="">
     </span>
     <span>商城</span>
   </router-link>
   <router-link to='/ybutton' tag='div'>
     <span>      <img :src="this.$route.path=='/ybutton'?'https://10.url.cn/qqcourse_logo_ng/ajNVdqHZLLAcYPom22osQf2IIdMD25ofYUibd1USSQFHdiaUIiavicpAibgSReIqCky8gqY8ku5qdXsc/356':'https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=3993527673,913427098&fm=58'" alt="">
     </span>
     <span>交易</span>
   </router-link>
   <router-link to='/me' tag='div'>
     <span>      <img :src="this.$route.path=='/me'?'https://10.url.cn/qqcourse_logo_ng/ajNVdqHZLLAcYPom22osQf2IIdMD25ofYUibd1USSQFHdiaUIiavicpAibgSReIqCky8gqY8ku5qdXsc/356':'https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=3993527673,913427098&fm=58'" alt="">
     </span>
     <span>我的</span>
   </router-link>
  </div> -->
<div class="footer">
    <router-link v-for="(item,index) in data" :key="index" :to="item.path">
      <div class="divs" @click="tab_click(item.path)">
        <i :class="item.icon==true?'red':'bloack'">1</i>
        <i>{{item.title}}</i>  
      </div>  
    </router-link>    
</div>
</template>
<script>
import { constants } from 'crypto';
export default {
  props:{
    data:Array
  },
  data(){
    return{ 
      datai:this.data
    }
  },
  created(){
  },
  mounted(){
    console.log(this.data)
  },
  methods:{
    tab_click(path){
      const that=this;
      let datary=this.data;
        for(let i=0;i<datary.length;i++){ 
            datary[i].icon=false;
          if(datary[i].path==path){ 
            datary[i].icon=true;
             console.log('---------',datary[i].path)
          }
        }    
      this.datai=datary;
      console.log(datary)      
    }
  }   
}
</script>
<style scoped>
.footer{
  position: fixed;
  bottom:0px;
  left:0px;
  width:100%;
  display:flex;
  justify-content: space-between;
}
.footer .divs{padding:10px;}
.red{color:red;font-size:14px;}
.bloack{font-size:14px;color:black;}
/* ---------------- */
 .footbar{
  width: 100%;
  height: 2.613333rem;
  position: fixed;
  bottom: 0;
  display: flex;
  align-items: center;
  background: white;
  border-top: 1px solid #eeeeee;
  color: #999999;
}
.footbar span{
  display: block;
  font-size: .64rem;
}
.footbar div{
  flex: 1;
  text-align: center;
}
.footbar img{
  height: 1.066667rem;
}
.footbar .router-link-exact-active{
  color: #2F83C3;
}
.footbar .active{
  color: #2F83C3;
}
</style>

4 顯示底部菜單欄的界面 引入tabbar 組件

<template>
  <div class="index">
    主頁
    <router-view></router-view>
    <tabbar :data="tabbarData"/>
  </div>
</template>
<script>
import tabbar from '../components/tabbaer'
export default {
name:'index',
data() {
  return {
    tabbarData:[
      {title:'微信',icon:true,path:'/charts'},
      {title:'通訊錄',icon:false,path:'/adiscover'},
      {title:'發(fā)現(xiàn)',icon:false,path:'/ybutton'},
      {title:'我的',icon:false,path:'/me'},
      ]
  }
},
components:{
  tabbar,
},
}
</script>
<style scoped>
  .index{
    width:100%;
    height:100%;
    overflow: hidden;
    padding:16px;
    box-sizing:border-box;
    }   
</style>

5 這就是最終結(jié)果

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue實(shí)現(xiàn)一個帶有緩存功能的Tab頁簽功能

    Vue實(shí)現(xiàn)一個帶有緩存功能的Tab頁簽功能

    在現(xiàn)代?Web?應(yīng)用中,Tab?頁簽功能是非常常見的一種交互模式,它可以幫助用戶在不同的視圖間快速切換,而不會丟失當(dāng)前視圖的狀態(tài),本文將介紹如何在?Vue?項目中實(shí)現(xiàn)一個帶有緩存功能的?Tab?頁簽功能,需要的朋友可以參考下
    2024-08-08
  • 關(guān)于Vue中keep-alive的作用及使用方法

    關(guān)于Vue中keep-alive的作用及使用方法

    keep-alive是Vue的內(nèi)置組件,當(dāng)它包裹動態(tài)組件時,會緩存不活動的組件實(shí)例,該組件將不會銷毀,這篇文章主要介紹了關(guān)于Vue中keep-alive的作用是什么?怎么使用,需要的朋友可以參考下
    2023-04-04
  • 關(guān)于vue3中setup函數(shù)的使用

    關(guān)于vue3中setup函數(shù)的使用

    這篇文章主要介紹了關(guān)于vue3中setup函數(shù)的使用,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vue3如何直接修改reactive定義的變量

    vue3如何直接修改reactive定義的變量

    這篇文章主要介紹了vue3如何直接修改reactive定義的變量問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • Vue利用canvas實(shí)現(xiàn)移動端手寫板的方法

    Vue利用canvas實(shí)現(xiàn)移動端手寫板的方法

    本篇文章主要介紹了Vue利用canvas實(shí)現(xiàn)移動端手寫板的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-05-05
  • 詳解vue修改elementUI的分頁組件視圖沒更新問題

    詳解vue修改elementUI的分頁組件視圖沒更新問題

    這篇文章主要介紹了詳解vue修改elementUI的分頁組件視圖沒更新問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • vue3父子同信的雙向數(shù)據(jù)的項目實(shí)現(xiàn)

    vue3父子同信的雙向數(shù)據(jù)的項目實(shí)現(xiàn)

    我們知道的是,父傳子的通信,和子傳父的通信,那如何實(shí)現(xiàn)父子相互通信的呢,本文就來詳細(xì)的介紹一下,感興趣的可以了解一下
    2023-08-08
  • Vue實(shí)現(xiàn)控制商品數(shù)量組件封裝及使用

    Vue實(shí)現(xiàn)控制商品數(shù)量組件封裝及使用

    這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)控制商品數(shù)量組件的封裝及使用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • vue使用v-model進(jìn)行跨組件綁定的基本實(shí)現(xiàn)方法

    vue使用v-model進(jìn)行跨組件綁定的基本實(shí)現(xiàn)方法

    這篇文章主要給大家介紹了關(guān)于vue使用v-model進(jìn)行跨組件綁定的基本實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • vue使用vuedraggable插件實(shí)現(xiàn)拖拽效果

    vue使用vuedraggable插件實(shí)現(xiàn)拖拽效果

    這篇文章主要介紹了vue使用vuedraggable插件實(shí)現(xiàn)拖拽效果,本文分步驟介紹了安裝vuedraggable插件的方法及頁面引入的方法,需要的朋友可以參考下
    2024-04-04

最新評論