uniapp中Tabbar突出图标功能实现

本文介绍了如何在uni-app中配置pages.json的tabBar属性,包括颜色、选中状态、边框样式等,并展示了如何在App.vue中监听并处理tabBar中间按钮的点击事件,实现页面跳转到指定路径。
摘要由CSDN通过智能技术生成

                                     

 在pages.json里面配置tabbar属性

"tabBar": {
      "color": "#999999",
      "selectedColor": "#FA436A",
      "borderStyle": "black",
      "backgroundColor": "#ffffff",
      "height": "50px",
      "fontSize": "10px",
      "iconWidth": "24px",
      "spacing": "3px",
      "midButton": {
      
        "height": "70px", //修改距离底下的高度 
        "iconWidth": "50px", // 缩放图片大小 自己调整 
        "iconPath": "static/33cd2904c1d0e00cce947d9248eee4a.png",
        "selectedIconPath": "static/5x471a3cb9de2330f0d7ee72547772bd7.png",
        "text": "油枪"
      },
      "list": [
        {
          "pagePath": "pages/workbenck/workbenck",
          "iconPath": "static/icon/gongzuotai-copy.png",
          "selectedIconPath": "static/workdeskPink.png",
          "text": "工作台"
        },
        {
          "pagePath": "pages/mine/mine",
          "iconPath": "static/icon/zhanghao.png",
          "selectedIconPath": "static/myPersonPink.png",
          "text": "我的"
        }
      ]
    },

tabbar配置minbutton 点击完从哪里跳转? 在App.vue当中配置

onLaunch: function() {
		console.log('App Launch')
		uni.onTabBarMidButtonTap(()=>{
        console.log(123) //你先试试点一下有没有反应 有反应了再跳
        uni.navigateTo({
          url:'/pages/sweepCode/sweepCode'
        })
		  });
      
		},

UniApp(原DCloud框架)中,微信小程序的 tabBar 允许自定义样式,包括改变中间图标的凸起效果。如果你想让某个 tabBar 的中间图标显得更突出,你可以通过调整 tabBar 的样式来实现。以下是步骤: 1. 首先,在项目的 `pages.json` 文件中,找到需要设置样式的 tabBar 配置。每个 tabBar 项都有一个配置对象,其中包含 "iconPath" 和 "selectedIconPath" 字段。 ```json { "tabBar": { "custom": true, "color": "#fff", "selectedColor": "#00B7FF", "borderStyle": "#DDDDDD", "list": [ { "pagePath": "index", "text": "首页", "iconPath": "path/to/home-icon.png", "selectedIconPath": "path/to/home-selected-icon.png" }, // ... 更多 tabBar... { "pagePath": "tab-bar-item", "text": "凸起图标页", "iconPath": "path/to/emphasis-icon.png", "selectedIconPath": "path/to/emphasis-selected-icon.png" } ] } } ``` 2. 然后,在对应的 tabBar 页面组件的.wxss 文件中,添加自定义样式。为了使图标凸起,你可以模拟伪元素和边框样式: ```css .tab-bar-item .tab-bar-item__custom { position: relative; } .tab-bar-item .tab-bar-item__custom::before { content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 48%; /* 图标尺寸的一半 */ height: 48%; border-radius: 50%; background-color: rgba(255, 255, 255, 0.6); /* 可以调整透明度 */ box-shadow: 0 3px 4px rgba(0, 0, 0, 0.1); } .tab-bar-item.tab-bar-item_selected .tab-bar-item__custom::before { background-color: #00B7FF; /* 选中状态颜色 */ } ``` 记得替换 `path/to/*-icon.png` 为实际的图片路径。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值