微信小程序入门之常见错误

微信小程序开发遇到的常见问题,整理集合
lbxx

微信小程序–TabBar不显示

错误现象是,项目的app.json使用以下代码,却没有如期望那样在屏幕底部出现TabBar。

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
"pages":[
"pages/clickDemo/clickDemo",
"pages/logs/logs",
"pages/index/index",
"pages/mypage/mypage"
],
"window": {
"backgroundTextStyle": "dark ",
"navigationBarBackgroundColor": "#ddd",
"navigationBarTitleText": "Tabbar Demo",
"navigationBarTextStyle": "black",
"backgroundColor": "#ff0000"
},
"tabBar": {
"color": "#000000",
"borderStyle": "#000",
"selectedColor": "#9999FF",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "image/location_normal.png",
"selectedIconPath": "image/location_selected.png"
},
{
"pagePath": "pages/logs/logs",
"text": "设置",
"iconPath": "image/setting_normal.png",
"selectedIconPath": "image/setting_selecred.png"
}
]
}
}

原因

app.json头部的pages数组的第一项”pages/clickDemo/clickDemo”没有成为tabBar的一员,也就是在tabBar的list数组内没有链接clickDemo页面的条目。
具体对策有两种。
一,我们在list数组内加入链接clickDemo页面的条目,
二,把pages数组的第一项设置为”pages/index/index”,或者设置为”pages/logs/logs”。也就是说,pages数组的第一项必须是tabBar的list数组的一员。

×

谢谢客官

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. 微信小程序–TabBar不显示
    1. 1.1. 代码
    2. 1.2. 原因
,