萤火星
萤火星
  • 发布:2024-01-26 15:41
  • 更新:2024-01-29 17:18
  • 阅读:228

【报Bug】setTabBarStyle APP下无法动态设置midButton

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows11

HBuilderX类型: 正式

HBuilderX版本号: 3.8.7

手机系统: Android

手机系统版本号: Android 13

手机厂商: 小米

手机机型: 红米k50

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<template>  
    <view class="content">  
        页面 - 1  
        <button @tap="showButton">显示中间按钮</button>  
        <button @tap="hideButton1">隐藏中间按钮方法1</button>  
        <button @tap="hideButton2">隐藏中间按钮方法2</button>  
        <button @tap="showtabBar">显示tabBar</button>  
        <button @tap="hidetabBar">隐藏tabBar</button>  
        <button @tap="switchIcon">更换图标</button>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                title: 'Hello'  
            }  
        },  
        onLoad() {  
        },  
        methods: {  
            showButton(){  
                uni.setTabBarStyle({  
                    midButton : {  
                        "iconPath": "static/img/tabbar/add.png"  
                    }  
                })  
            },            
            hideButton1(){  
                uni.setTabBarStyle({  
                    midButton: undefined  
                })  
            },        
            hideButton2(){  
                uni.setTabBarStyle({  
                    midButton: {  
                        "iconPath": "",  
                        "width": "0px"  
                    }  
                })  
            },  
            showtabBar(){  
                uni.showTabBar()  
            },  
            hidetabBar(){  
                uni.hideTabBar()  
            },  
            switchIcon(){  
                uni.setTabBarStyle({  
                    midButton : {  
                        "iconPath": "static/img/tabbar/home.png"  
                    }  
                })  
            }  
        }  
    }  
</script>  

<style>  
    .content {  
        text-align: center;  
        height: 400upx;  
        margin-top: 200upx;  
    }  
</style>

操作步骤:

点击“隐藏中间按钮方法1”

预期结果:

tabBar中midButton不显示

实际结果:

安卓APP中tabBar中midButton没有变化,H5下midButton消失

bug描述:

安卓app下,无法通过下面代码隐藏midButton

hideButton1(){  
    uni.setTabBarStyle({  
        midButton: undefined  
    })  
},        
hideButton2(){  
    uni.setTabBarStyle({  
        midButton: {  
            "iconPath": "",  
            "width": "0px"  
        }  
    })  
},
2024-01-26 15:41 负责人:无 分享
已邀请:
喜欢技术的前端

喜欢技术的前端 - QQ---445849201

4.0.2024012711-alpha 版本

可以隐藏  
hideButton2(){    
                uni.setTabBarStyle({    
                    midButton: {    
                        "iconPath": "",    
                        "width": "0px"    
                    }    
                })    
            },   
可以更换  
switchIcon(){    
                uni.setTabBarStyle({    
                    midButton : {    
                        "iconPath": "static/img/tabbar/home.png"    
                    }    
                })    
            } 

要回复问题请先登录注册