微信小程序开发之自定义菜单tabbar

做这个 遇到问题比较多,特此记录以便查看,直接上代码:

一、app.js

控制原有菜单隐藏、启用新菜单、菜单列表,集中在这里控制

hideTabBar这个很关键,解决苹果6S导致的双导航栏:原文https://blog.csdn.net/czp555/article/details/87258301

hideTabBar: function () { wx.hideTabBar({ fail: function () { setTimeout(function () { wx.hideTabBar() }, 500) } }); }, editTabbar: function() { let tabbar = this.globalData.tabBar; let currentPages = getCurrentPages(); let _this = currentPages[currentPages.length - 1]; let pagePath = _this.route; (pagePath.indexOf(\'/\') != 0) && (pagePath = \'/\' + pagePath); for (let i in tabbar.list) { tabbar.list[i].selected = false; (tabbar.list[i].pagePath == pagePath) && (tabbar.list[i].selected = true); } _this.setData({ tabbar: tabbar }); }, globalData: { tabBar: { "color": "#f3f3f3", "selectedColor": "#f3f3f3", "borderStyle": "white", "backgroundColor": "#ff731d", "list": [{ "pagePath": "/youfan_market/pages/index/index", "text": "首页", "iconPath": "/youfan_market/resource/images/tabBar/home.png", "selectedIconPath": "/youfan_market/resource/images/tabBar/home.png" }, { "pagePath": "/youfan_market/pages/category/category", "text": "分类", "iconPath": "/youfan_market/resource/images/tabBar/category.png", "selectedIconPath": "/youfan_market/resource/images/tabBar/category.png" }, { "pagePath": "/youfan_market/pages/user/index", "text": "分享转发", "iconPath": "/youfan_market/resource/images/tabBar/share.png", "selectedIconPath": "/youfan_market/resource/images/tabBar/share.png", isShare: true }, { "pagePath": "/youfan_market/pages/cart/cart", "text": "购物车", "iconPath": "/youfan_market/resource/images/tabBar/cart.png", "selectedIconPath": "/youfan_market/resource/images/tabBar/cart.png" }, { "pagePath": "/youfan_market/pages/user/index", "text": "我的", "iconPath": "/youfan_market/resource/images/tabBar/user.png", "selectedIconPath": "/youfan_market/resource/images/tabBar/user.png" } ] } },

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwzjjg.html