一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

node.js|vue.js|jquery|angularjs|React|json|js教程|

服務(wù)器之家 - 編程語(yǔ)言 - JavaScript - uni-app 自定義底部導(dǎo)航欄的實(shí)現(xiàn)

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

2021-12-09 15:19Joanna同學(xué) JavaScript

這篇文章主要介紹了uni-app 自定義底部導(dǎo)航欄的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

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

1. tabbar 組件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<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)閉頁(yè)面切換動(dòng)畫效果,

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<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)航欄的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)uni-app 底部導(dǎo)航欄內(nèi)容請(qǐng)搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://juejin.cn/post/6904866034990186509

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 亚洲国产精品一区二区首页 | 日韩免费高清专区 | 国产一区二区三区久久精品 | 四虎新网站 | 成年人视频免费在线播放 | 91短视频在线观看2019 | 成年女人免费 | 性欧美sexvideo另类 | 精品国产麻豆免费人成网站 | 国产在线步兵一区二区三区 | 亚洲激情 欧美 | 荡女人人爱全文免费阅读 | 2021国产麻豆剧传媒剧情最新 | 亚洲天堂三区 | 嫩草影院永久入口在线观看 | 亚洲 欧美 日韩 国产 视频 | 隔壁老王国产在线精品 | 国产精品成人在线播放 | 国产酒店自拍 | 久久精品国产色蜜蜜麻豆国语版 | 色交视频 | 视频一本大道香蕉久在线播放 | 婷婷综合久久中文字幕 | 国产精品视频免费看 | 亚洲视频中文 | 精品淑女少妇AV久久免费 | 日本在线播放视频 | 国产99青草全福视在线 | 日韩欧美国产免费看清风阁 | 成人午夜爽爽爽免费视频 | 激情小视频 | 男人曰女人 | 欧美精品一国产成人性影视 | 美女操穴视频 | 4438全国最大免费观看 | 免费看男女做好爽好硬视频 | 日本护士xxxx视频 | 香蕉久久ac一区二区三区 | 2018久久精品热在线观看 | 4虎tv| 67id人成观看免费 |