uni-app 自定义底部导航栏的实现
网络编程 2021-07-04 14:07www.168986.cn编程入门
这篇文章主要介绍了uni-app 自定义底部导航栏的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们狼蚁网站SEO优化随着长沙网络推广来一起学习学习吧
这是我目前发现较好的uni-app 自定义底部导航栏方法,其他方法的缺点主要是在切换时,要么会闪烁,要么会每点击一下,都会请求一次数据。如果有其他更好的方法,欢迎评论留言,最近才开始用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使用频次较高,就设为全局变量了 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是为了关闭页面切换动画效果,
<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; }
到此这篇关于uni-app 自定义底部导航栏的实现的文章就介绍到这了,更多相关uni-app 底部导航栏内容请搜索狼蚁SEO以前的文章或继续浏览狼蚁网站SEO优化的相关文章希望大家以后多多支持狼蚁SEO!
编程语言
- 甘肃哪有关键词排名优化购买方式有哪些
- 甘肃SEO如何做网站优化
- 河南seo关键词优化怎么做电话营销
- 北京SEO优化如何做QQ群营销
- 来宾百度关键词排名:提升您网站曝光率的关键
- 卢龙关键词优化:提升您网站排名的策略与技巧
- 山东网站优化的注意事项有哪些
- 四川整站优化怎样提升在搜索引擎中的排名
- 疏附整站优化:提升网站性能与用户体验的全新
- 海南seo主要做什么工作售后服务要做到哪些
- 荣昌百度网站优化:提升您网站的搜索引擎排名
- 河北seo网站排名关键词优化如何做SEO
- 江西优化关键词排名推广售后保障一般有哪些
- 古浪SEO优化:提升你的网站可见性
- 西藏网站排名优化怎么把网站排名在百度首页
- 如何提升阳东百度快照排名:详尽指南