uniapp实现tabbar中间凸出效果

2023-10-13 05:30

本文主要是介绍uniapp实现tabbar中间凸出效果,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 

1.实现一个自定义的tabbar

1.1在components下创建一个tabbar文件

<view class="tabbar-container"><view class="tabbar-item" v-for="(item, index) in tabbarList" :class="[item.centerItem ? ' center-item' : '']"@click="changeItem(item)"><view class="item-top"><image :src="currentItem == item.id ? item.selectIcon : item.icon"></image></view><view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']"><text>{{ item.text }}</text></view></view></view><script>export default {props: {currentPage: {type: Number,default: 0}},data() {return {currentItem: 0,tabbarList: [{id: 0,path: '/pages/tabbar/home/index',icon: '/static/tabbar/images/home.png',selectIcon: '/static/tabbar/images/home_select.png',text: '首页',centerItem: false},{id: 1,path: '/pages/tabbar/goods/index',icon: '/static/tabbar/images/goods.png',selectIcon: '/static/tabbar/images/home_select.png',text: '我的订单',centerItem: false},{id: 2,path: '/pages/tabbar/vip/vip',icon: '/static/tabbar/images/vip.png',selectIcon: '/static/tabbar/images/home_select.png',text: '成为会员',centerItem: true},{id: 3,path: '/pages/tabbar/team/team',icon: '/static/tabbar/images/team.png',selectIcon: '/static/tabbar/images/home_select.png',text: '我的团队',centerItem: false},{id: 4,path: '/pages/tabbar/user/user',icon: '/static/tabbar/images/user.png',selectIcon: '/static/tabbar/images/user_select.png',text: '会员中心',centerItem: false}]};},mounted() {this.currentItem = this.currentPage;uni.hideTabBar();},methods: {changeItem(item) {let _this = this;_this.currentItem = item.id;uni.switchTab({url: item.path});}}};
</script>

2.pages.js配置——tabbar正常配置

"tabBar": {"custom": false,//防止二次点击失效/*颜色*/"color": "#000000",/*选中之后的*/"selectedColor": "#29B2EC",/*边框*/"borderStyle": "black","backgroundColor": "#f7f7f7","midButton": {"text": "xxx","pagePath": "pages/tabbar/vip/vip","iconPath": "static/tabbar/images/vip.png","selectedIconPath": "static/tabbar/images/vip.png"},"list": [{"iconPath": "static/tabbar/images/home.png","selectedIconPath": "static/tabbar/images/home_select.png","text": "首页","pagePath": "pages/tabbar/home/index"},{/*图标路径*/"iconPath": "static/tabbar/images/goods.png",/*点击图片后的路径*/// "selectedIconPath": "static/tabbar/user_select.png",/*文本文字*/"text": "xxx",/*显示的路径*/"pagePath": "pages/tabbar/goods/index"},{/*图标路径*/"iconPath": "static/tabbar/images/vip.png",/*点击图片后的路径*/// "selectedIconPath": "static/tabbar/images/user_select.png",/*文本文字*/"text": "xxx",/*显示的路径*/"pagePath": "pages/tabbar/vip/vip"},{/*图标路径*/"iconPath": "static/tabbar/images/team.png",/*点击图片后的路径*/// "selectedIconPath": "static/tabbar/images/user_select.png",/*文本文字*/"text": "xxx",/*显示的路径*/"pagePath": "pages/tabbar/team/team"},{/*图标路径*/"iconPath": "static/tabbar/images/user.png",/*点击图片后的路径*/"selectedIconPath": "static/tabbar/images/user_select.png",/*文本文字*/"text": "xxx",/*显示的路径*/"pagePath": "pages/tabbar/user/user"}]

3.tabbar全局引入,在main.js中引入


import Tabbar from "components/tabbar.vue"
Vue.component('tabbar', Tabbar)

4.tabbar局部引入,在你所需要用到的地方引入

<view class="container"><tabbar :current-page="0"></tabbar>
</view><script>import tabbar from '@/compenets/tabbar.vue'export default {components:{tabbar }onShow: function() {//隐藏pages.js配置的tabbaruni.hideTabBar({animation: true})console.log('App Show')},}

这篇关于uniapp实现tabbar中间凸出效果的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/201089

相关文章

springboot filter实现请求响应全链路拦截

《springbootfilter实现请求响应全链路拦截》这篇文章主要为大家详细介绍了SpringBoot如何结合Filter同时拦截请求和响应,从而实现​​日志采集自动化,感兴趣的小伙伴可以跟随小... 目录一、为什么你需要这个过滤器?​​​二、核心实现:一个Filter搞定双向数据流​​​​三、完整代码

SpringBoot利用@Validated注解优雅实现参数校验

《SpringBoot利用@Validated注解优雅实现参数校验》在开发Web应用时,用户输入的合法性校验是保障系统稳定性的基础,​SpringBoot的@Validated注解提供了一种更优雅的解... 目录​一、为什么需要参数校验二、Validated 的核心用法​1. 基础校验2. php分组校验3

Python实现AVIF图片与其他图片格式间的批量转换

《Python实现AVIF图片与其他图片格式间的批量转换》这篇文章主要为大家详细介绍了如何使用Pillow库实现AVIF与其他格式的相互转换,即将AVIF转换为常见的格式,比如JPG或PNG,需要的小... 目录环境配置1.将单个 AVIF 图片转换为 JPG 和 PNG2.批量转换目录下所有 AVIF 图

Pydantic中model_validator的实现

《Pydantic中model_validator的实现》本文主要介绍了Pydantic中model_validator的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价... 目录引言基础知识创建 Pydantic 模型使用 model_validator 装饰器高级用法mo

AJAX请求上传下载进度监控实现方式

《AJAX请求上传下载进度监控实现方式》在日常Web开发中,AJAX(AsynchronousJavaScriptandXML)被广泛用于异步请求数据,而无需刷新整个页面,:本文主要介绍AJAX请... 目录1. 前言2. 基于XMLHttpRequest的进度监控2.1 基础版文件上传监控2.2 增强版多

Redis分片集群的实现

《Redis分片集群的实现》Redis分片集群是一种将Redis数据库分散到多个节点上的方式,以提供更高的性能和可伸缩性,本文主要介绍了Redis分片集群的实现,具有一定的参考价值,感兴趣的可以了解一... 目录1. Redis Cluster的核心概念哈希槽(Hash Slots)主从复制与故障转移2.

springboot+dubbo实现时间轮算法

《springboot+dubbo实现时间轮算法》时间轮是一种高效利用线程资源进行批量化调度的算法,本文主要介绍了springboot+dubbo实现时间轮算法,文中通过示例代码介绍的非常详细,对大家... 目录前言一、参数说明二、具体实现1、HashedwheelTimer2、createWheel3、n

使用Python实现一键隐藏屏幕并锁定输入

《使用Python实现一键隐藏屏幕并锁定输入》本文主要介绍了使用Python编写一个一键隐藏屏幕并锁定输入的黑科技程序,能够在指定热键触发后立即遮挡屏幕,并禁止一切键盘鼠标输入,这样就再也不用担心自己... 目录1. 概述2. 功能亮点3.代码实现4.使用方法5. 展示效果6. 代码优化与拓展7. 总结1.

Mybatis 传参与排序模糊查询功能实现

《Mybatis传参与排序模糊查询功能实现》:本文主要介绍Mybatis传参与排序模糊查询功能实现,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、#{ }和${ }传参的区别二、排序三、like查询四、数据库连接池五、mysql 开发企业规范一、#{ }和${ }传参的

Docker镜像修改hosts及dockerfile修改hosts文件的实现方式

《Docker镜像修改hosts及dockerfile修改hosts文件的实现方式》:本文主要介绍Docker镜像修改hosts及dockerfile修改hosts文件的实现方式,具有很好的参考价... 目录docker镜像修改hosts及dockerfile修改hosts文件准备 dockerfile 文