How to solve the problem that the WeChat applet cannot display the tabBar properly

1. Problem


        When writing the WeChat applet, under the premise that our relevant configuration is "完全正确", the WeChat applet's tabBar不能正常显示.


As shown below:
Insert image description here


2. Solution ideas


  1. Check whether the page referenced in our tabBar has been registered in pages. If this page is not registered, it should be adjusted in time to register the page in pages;
  2. If the page has been registered but still not displayed, you need to check whether there is an error in the path used by the page. If there is an error, correct it. If not, see the solution below;
  3. tabBar中的页面路径在pages中的排序(推荐先检查这个)

3. Solution


Solution:
        Put the path of tabBar页面文件 into the path of . 非tabBar页面上面


3.1 Unable to display normally


app.jsonConfiguration file (不能正常显示 case):

{
    
    
    //页面创建
  "pages":[
    //非tabBar页面
    "pages/index/index",
    "pages/logs/logs"
      //tabBar页面
    "pages/home/home",
    "pages/msg/msg",
    
  ],
    //tabBar菜单选项配置
  "tabBar": {
    
    
    "position": "bottom",
    "borderStyle":"black",
    "color": "#75878a",
    "selectedColor": "#f00056",
    "backgroundColor": "#f0f0f4",
    "list": [{
    
    
      "pagePath": "pages/home/home",
      "text": "主页",
      "iconPath": "/icon/tabBar/home1.png",
      "selectedIconPath": "/icon/tabBar/home2.png"
    },
    {
    
    
      "pagePath": "pages/msg/msg",
      "text": "消息页面",
      "iconPath": "/icon/tabBar/msg1.png",
      "selectedIconPath": "/icon/tabBar/msg2.png"
    }]
  }
}

//配置项文件中不能有注释

Note:
tabBar page必须放到所有页面的前面, otherwise tabBar cannot be displayed

As shown in the following code, if the "pages/home/home"和"pages/msg/msg"tabbar page is placed after "pages/index/index","pages/logs/logs", the tabBar menu option cannot be displayed.


3.2 Normal display


app.jsonConfiguration file (正常显示 case):

{
    
    
    //页面创建
  "pages":[
    //tabBar页面
    "pages/home/home",
    "pages/msg/msg",
    //非tabBar页面
    "pages/index/index",
    "pages/logs/logs"   
  ],
    //tabBar菜单选项配置
  "tabBar": {
    
    
    "position": "bottom",
    "borderStyle":"black",
    "color": "#75878a",
    "selectedColor": "#f00056",
    "backgroundColor": "#f0f0f4",
    "list": [{
    
    
      "pagePath": "pages/home/home",
      "text": "主页",
      "iconPath": "/icon/tabBar/home1.png",
      "selectedIconPath": "/icon/tabBar/home2.png"
    },
    {
    
    
      "pagePath": "pages/msg/msg",
      "text": "消息页面",
      "iconPath": "/icon/tabBar/msg1.png",
      "selectedIconPath": "/icon/tabBar/msg2.png"
    }]
  }
}

//配置项文件中不能有注释

Insert image description here

Guess you like

Origin blog.csdn.net/qq_24484317/article/details/134192930