您好,登錄后才能下訂單哦!
利用uni-app怎么對底部導(dǎo)航欄進(jìn)行自定義?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
1. tabbar 組件
<template> <view class="tabbar-container"> <view : v-for="(item, index) in tabbarList" :key="index" @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 :> <tab-bar :currentIndex="currentIndex" class="tabbar-container" @getCurrentIndex="getCurrentIndex" /> <swiper duration="0" disable-touch :current="currentIndex" > <swiper-item> <scroll-view scroll-y > <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; }
看完上述內(nèi)容,你們掌握利用uni-app怎么對底部導(dǎo)航欄進(jìn)行自定義的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。