最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

1 寫好界面

這是我寫好的四個(gè)界面

2 在router.js重定義路由

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

routes: [
  {
   path: '/',
   name: 'index',
   component:()=>import('./views/index'), //懶加載引入,路由
   children:[
    {path:'',redirect:'/charts'},//重定項(xiàng)
    {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)文章

  • vue3 axios 實(shí)現(xiàn)自動化api配置詳解

    vue3 axios 實(shí)現(xiàn)自動化api配置詳解

    這篇文章主要為大家介紹了vue3 axios 實(shí)現(xiàn)自動化api配置詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • 使用 Vue-TCB 快速在 Vue 應(yīng)用中接入云開發(fā)的方法

    使用 Vue-TCB 快速在 Vue 應(yīng)用中接入云開發(fā)的方法

    這篇文章主要介紹了如何使用 Vue-TCB 快速在 Vue 應(yīng)用中接入云開發(fā),本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-02-02
  • Vue2.0 http請求以及l(fā)oading展示實(shí)例

    Vue2.0 http請求以及l(fā)oading展示實(shí)例

    下面小編就為大家分享一篇Vue2.0 http請求以及l(fā)oading展示實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • element-ui 表格sortable排序手動js清除方式

    element-ui 表格sortable排序手動js清除方式

    這篇文章主要介紹了element-ui 表格sortable排序手動js清除方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • Vue采用異步渲染的原理分析

    Vue采用異步渲染的原理分析

    對于Vue為何采用異步渲染,簡單來說就是為了提升性能,因?yàn)椴徊捎卯惒礁?,在每次更新?shù)據(jù)都會對當(dāng)前組件進(jìn)行重新渲染,為了性能考慮,Vue會在本輪數(shù)據(jù)更新后,再去異步更新視圖,本文主要通過幾個(gè)實(shí)例給大家介紹一下Vue為何采用異步渲染,需要的朋友可以參考下
    2023-06-06
  • Vue.js 中制作自定義選擇組件的代碼附演示demo

    Vue.js 中制作自定義選擇組件的代碼附演示demo

    這篇文章主要介紹了Vue.js 中制作自定義選擇組件的代碼附演示demo,通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-02-02
  • Vue 中 a標(biāo)簽上href無法跳轉(zhuǎn)的解決方式

    Vue 中 a標(biāo)簽上href無法跳轉(zhuǎn)的解決方式

    今天小編大家分享一篇Vue 中 a標(biāo)簽上href無法跳轉(zhuǎn)的解決方式,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • vue.js實(shí)現(xiàn)圖書管理功能

    vue.js實(shí)現(xiàn)圖書管理功能

    這篇文章主要為大家詳細(xì)介紹了vue.js實(shí)現(xiàn)圖書管理功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-09-09
  • vue倒計(jì)時(shí)刷新頁面不會從頭開始的解決方法

    vue倒計(jì)時(shí)刷新頁面不會從頭開始的解決方法

    在本篇文章里小編給大家整理的是關(guān)于vue倒計(jì)時(shí)刷新頁面不會從頭開始的解決方法,需要的朋友們參考下。
    2020-03-03
  • 詳解key在Vue列表渲染時(shí)究竟起到了什么作用

    詳解key在Vue列表渲染時(shí)究竟起到了什么作用

    這篇文章主要介紹了key在Vue列表渲染時(shí)究竟起到了什么作用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04

最新評論

垦利县| 德保县| 福建省| 册亨县| 库尔勒市| 孝感市| 乐至县| 榆林市| 科技| 菏泽市| 桐梓县| 绥阳县| 辉县市| 独山县| 南阳市| 梁山县| 临沭县| 蒙阴县| 锦州市| 望谟县| 齐河县| 青龙| 瓦房店市| 营口市| 牟定县| 商水县| 汕头市| 遵化市| 米易县| 土默特左旗| 茶陵县| 克拉玛依市| 浪卡子县| 吉水县| 民乐县| 长顺县| 青冈县| 泸西县| 敦化市| 重庆市| 大余县|