In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "WeChat Mini Programs custom tabbar problem how to solve" related knowledge, the editor through the actual case to show you the operation process, the operation method is simple and fast, practical, I hope that this "WeChat Mini Programs custom tabbar problem how to solve" article can help you solve the problem.
1. First define tabbar "tabBar" in app.json according to official components: {"custom": true, "backgroundColor": "# FFFFFF", "borderStyle": "white", "list": [{"pagePath": "pages/index/index", "text": "homepage", "iconPath": ". / images/home.png" "selectedIconPath": ". / images/home.png"}, {"pagePath": "pages/me/me", "text": "personal Center", "iconPath": ". / images/me.png", "selectedIconPath": ". / images/me.png"}]}, "usingComponents": {} 2. Create custom tabbar components in the project root directory
Highlight: root directory. Please see the figure below. Not putting the root directory will result in this.getTabBar = null.
3. The components are as follows:
Custom-tab-bar/index.js
Component ({data: {selected: 0, color: "# 7A7E83", selectedColor: "# 3cc51f", list: [{pagePath: ".. / pages/index/index", iconPath: ".. / images/home.png", selectedIconPath: ".. / images/home.png", text: "homepage"}, {pagePath: ".. /.. / pages/me/me" IconPath: ".. / images/me.png", selectedIconPath: ".. / images/me.png", text: "personal Center"}}, attached () {} Methods: {switchTab (e) {const data = e.currentTarget.dataset const url = data.path wx.switchTab ({url}) this.setData ({selected: data.index})}})
Custom-tab-bar/index.json
{"component": true}
Custom-tab-bar/index.wxml
{{item.text}}
Custom-tab-bar/index.wxss
.tab-bar {position: fixed; bottom: 0; left: 0; right: 0; height: 48px; background: white; display: flex; padding-bottom: env (safe-area-inset-bottom);} .tab-bar-border {background-color: rgba (0,0,0,0.33); position: absolute; left: 0; top: 0; width: 100%; height: 1px; transform: scaleY (0.5);} .tab-bar-item {flex: 1 Text-align: center; display: flex; justify-content: center; align-items: center; flex-direction: column;} .tab-bar-item cover-image {width: 27px; height: 27px;} .tab-bar-item cover-view {font-size: 10px;} 4. Each page component under pages introduces tabbar
Take the home page as an example:
Pages/index.json
{"usingComponents": {"custom-tab-bar": ".. /.. / custom-tab-bar/index"}}
Pages/index.js
Page ({onShow: function () {if (typeof this.getTabBar = 'function' & & this.getTabBar ()) {this.getTabBar () .setData ({selected: 0})}}))
Pages/index.wxml
This is the end of the content about "how to solve the WeChat Mini Programs custom tabbar problem". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.