• uni-app tabBar中间按钮 之 midButton


    midButton 中间按钮 仅在 list 项为偶数时有效 , 需要App 2.3.4+、H5 3.0.0+以上版本

    midButton 属性说明

    属性类型必填默认值描述
    width String 80px 中间按钮的宽度,tabBar 其它项为减去此宽度后平分,默认值为与其它项平分宽度
    height String 50px 中间按钮的高度,可以大于 tabBar 高度,达到中间凸起的效果
    text String   中间按钮的文字
    iconPath String   中间按钮的图片路径
    iconWidth String 24px 图片宽度(高度等比例缩放)
    backgroundImage String   中间按钮的背景图片路径

    midButton没有pagePath,需监听点击事件,自行处理点击后的行为逻辑。监听点击事件为调用API:uni.onTabBarMidButtonTap,详见https://uniapp.dcloud.io/api/ui/tabbar?id=ontabbarmidbuttontap

     导航代码演示:

    "tabBar": {
            "color": "#808080",
            "selectedColor": "#dd0000",
            "backgroundColor": "#ffffff",
            //中间件  2~4生效
            "midButton":{
                    "iconPath":"static/tab-find-current.png",
                    "height":"80px",
                    "iconWidth":"60px",
                    "text":"发布"
                },
            "list": [{
                    "text": "首页",
                    "iconPath": "static/tab-home.png",
                    "selectedIconPath": "static/tab-home-current.png",
                    "pagePath": "pages/index/index"
                },
                {
                    "text": "分类",
                    "iconPath": "static/tab-find.png",
                    "selectedIconPath": "static/tab-find-current.png",
                    "pagePath": "pages/category/category"
                },
                
                {
                    "text": "消息",
                    "iconPath": "static/tab-msg.png",
                    "selectedIconPath": "static/tab-msg-current.png",
                    "pagePath": "pages/message/message"
                    
                },
                {
                    "text": "我的",
                    "iconPath": "static/tab-me.png",
                    "selectedIconPath": "static/tab-me-current.png",
                    "pagePath": "pages/me/me"
                }
            ]
        }

    监听中间按钮的点击事件演示

     在 App.vue 全局里面添加下面代码:

    uni.onTabBarMidButtonTap(()=>{
            console.log("点击了");
    
            });
  • 相关阅读:
    lesson4Embedding-fastai
    lesson3 overfitting -fastai
    cell-augmented
    ROI-Align解决方案
    软件安装
    lesson1-fastai
    mask-rcnn
    代码basic讲解
    skearn/pandas
    HDU1087上升子序列的最大和
  • 原文地址:https://www.cnblogs.com/shenguoan/p/14352885.html
Copyright © 2020-2023  润新知