uni.setTabBarStyle({color:"#7A7E83",selectedColor:"#007AFF",backgroundColor:"#F8F8F8",borderStyle:"black",});
exportdefault{methods:{// 初始化 tabBar 样式initTabBar(){// 设置 tabBar 整体样式 uni.setTabBarStyle({color:"#7A7E83",selectedColor:"#007AFF",backgroundColor:"#FFFFFF",borderStyle:"black",});// 设置各 tab 项 uni.setTabBarItem({index:0,text:"首页",iconPath:"/static/tabbar/home.png",selectedIconPath:"/static/tabbar/home-selected.png",}); uni.setTabBarItem({index:1,text:"分类",iconPath:"/static/tabbar/category.png",selectedIconPath:"/static/tabbar/category-selected.png",}); uni.setTabBarItem({index:2,text:"购物车",iconPath:"/static/tabbar/cart.png",selectedIconPath:"/static/tabbar/cart-selected.png",}); uni.setTabBarItem({index:3,text:"我的",iconPath:"/static/tabbar/user.png",selectedIconPath:"/static/tabbar/user-selected.png",});},// 更新购物车数量显示updateCartBadge(count){if(count >0){ uni.setTabBarBadge({index:2,text: count.toString(),});}else{ uni.removeTabBarBadge({index:2,});}},// 显示消息红点showMessageDot(show){if(show){ uni.showTabBarRedDot({index:3,});}else{ uni.hideTabBarRedDot({index:3,});}},// 在特定页面隐藏 tabBarhideTabBarInPage(){ uni.hideTabBar({animation:true,});},// 返回页面时显示 tabBarshowTabBarInPage(){ uni.showTabBar({animation:true,});},},mounted(){this.initTabBar();},};