Home > WeChat Applet > Mini Program Development > WeChat Mini Program Example: Implementation Method of Customizing Navigation Bar

WeChat Mini Program Example: Implementation Method of Customizing Navigation Bar

不言
Release: 2018-08-21 17:29:12
Original
4932 people have browsed it

The content of this article is about WeChat applet examples: the implementation method of custom navigation bar, which has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

In the WeChat applet, the color of the navigation bar and some attributes of the copy can be set in the window in app.json, or in a single page. If it is a json file of a certain page For the configuration inside, you need to remove the window. For example, configure in app.json:

{
    "window":{
       "backgroundTextStyle":"light",
       "navigationBarBackgroundColor": "#fff",
       "navigationBarTitleText": "WeChat",
       "navigationBarTextStyle":"black",
       "navigationStyle": "custom"
     } }
Copy after login

Configure in the json file of a certain page:

{
  "backgroundTextStyle": "light",
  "navigationBarBackgroundColor": "#405f80",
  "navigationBarTitleText": "文与字",
  "navigationBarTextStyle": "white"}
Copy after login

For details, please refer to the official documentation: https://developers. weixin.qq.com/miniprogram/dev/framework/config.html

But sometimes the navigation bar required by the business is quite special, and the navigation bar provided by the mini program cannot meet the needs. In this case, it can only be customized. .

Let’s talk about the steps to customize the navigation bar first:

  • Add "navigationStyle": "custom" attribute to the window in app.json (the default attribute is "navigationStyle": "default"), then the default navigation bar of the mini program will disappear, as shown in the figure:
    WeChat Mini Program Example: Implementation Method of Customizing Navigation Bar

  • Then follow your own You need to add your own navigation bar to each page.

#Note: navigationStyle only takes effect in app.json. After custom is turned on, lower version clients need to be compatible. Switching the developer tool base library version to 1.7.0 (does not represent the lowest version, only for debugging) can easily switch to the old vision.
That is to say, this property can only be configured in app.json , if you want to customize the navigation bar in a single page, it is not possible. You must customize the navigation bar for all pages. Personally, I think this is quite confusing. Maybe the mini program will be optimized in the future.

Related recommendations:

Mini program example: Implementation code for paging data loading in mini program

WeChat mini program example: click event and long press event Code implementation

How to clear the default styles of buttons and scroll bars in mini programs (code)

The above is the detailed content of WeChat Mini Program Example: Implementation Method of Customizing Navigation Bar. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template