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

uni-app 自定義底部導(dǎo)航欄的實現(xiàn)

 更新時間:2020年12月11日 14:14:11   作者:Joanna同學(xué)  
這篇文章主要介紹了uni-app 自定義底部導(dǎo)航欄的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

這是我目前發(fā)現(xiàn)較好的uni-app 自定義底部導(dǎo)航欄方法,其他方法的缺點主要是在切換時,要么會閃爍,要么會每點擊一下,都會請求一次數(shù)據(jù)。如果有其他更好的方法,歡迎評論留言,最近才開始用uni-app寫項目,之前只是看了下文檔。

1. tabbar 組件

<template>
 <view class="tabbar-container">
  <view
   :style="{ color: currentIndex == index ? '#007EFF' : '#333333' }"
   v-for="(item, index) in tabbarList"
   :key="index"
   style="flex: 1"
   @click="switchTab(index)"
  >
   <view :class="'iconfont ' + item.icon" />
   <view class="title">{{ item.title }}</view>
  </view>
 </view>
</template>

mounted(){
 let dom = uni.createSelectorQuery().select('.tabbar-container')
  dom.boundingClientRect(e => {
   // tabbarHeight使用頻次較高,就設(shè)為全局變量了
    getApp().globalData.tabbarHeight = e.height
  }).exec()
}

<style scoped lang="scss">
.iconfont {
 font-size: 18px;
}

.tabbar-container {
 display: flex;
 justify-content: space-evenly;
 text-align: center;
 padding: 10px 0;
 background-color: #fff;
 box-shadow: 0 -1.5px 3px #eee;
 z-index: 999;

 .title {
  font-size: 12px;
 }
}
</style>

2. 引入

這里使用的是swiper,duration為0是為了關(guān)閉頁面切換動畫效果,

<template>
 <view :style="'height: calc(100vh - ' + tabbarHeight + 'px)'">
  <tab-bar
   :currentIndex="currentIndex"
   class="tabbar-container"
   @getCurrentIndex="getCurrentIndex"
  />
  <swiper duration="0" disable-touch :current="currentIndex" style="height: 100%">
   <swiper-item>
    <scroll-view scroll-y style="height: 100%">
     <home />
    </scroll-view>
   </swiper-item>
   <swiper-item>
    <todo-page />
   </swiper-item>
   <swiper-item>
    <launch-task />
   </swiper-item>
   <swiper-item>
    <my-page />
   </swiper-item>
  </swiper>
 </view>
</template>

mounted() {
 this.tabbarHeight = getApp().globalData.tabbarHeight
},

getCurrentIndex(e) {
 this.currentIndex = e;
}

到此這篇關(guān)于uni-app 自定義底部導(dǎo)航欄的實現(xiàn)的文章就介紹到這了,更多相關(guān)uni-app 底部導(dǎo)航欄內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

紫阳县| 宁陕县| 化德县| 高平市| 翁牛特旗| 岑溪市| 南充市| 兴仁县| 富川| 沾化县| 抚松县| 富民县| 西乌珠穆沁旗| 宁陵县| 阿拉善盟| 湖南省| 盐津县| 淄博市| 民和| 闽清县| 留坝县| 龙江县| 孝感市| 昌吉市| 黔江区| 察雅县| 策勒县| 二连浩特市| 西林县| 四川省| 石柱| 华池县| 彝良县| 平阴县| 潮安县| 高阳县| 富川| 内黄县| 航空| 庐江县| 汾阳市|