微信小程序 TabBar怎么设置默认选中?app.json中,tabbar按照如下写法,进入界面默认选择第一个tab(代码中为“首页”)

"tabBar": {
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "/images/icon/home.png",
"selectedIconPath": "/images/icon/home.png"
},
{
"pagePath": "pages/message/message",
"text": "消息",
"iconPath": "images/icon/message.png",
"selectedIconPath": "images/icon/message.png"
},
{
"pagePath": "pages/my/my",
"text": "我",
"iconPath": "/images/icon/my.png",
"selectedIconPath": "/images/icon/my.png"
}
]
}

假如我想把“消息”栏放在第一个,且默认选中,该怎么做?我自然而然的修改了”tabBar”里的顺序,如下:

"tabBar": {
"list": [
{
"pagePath": "pages/message/message",
"text": "消息",
"iconPath": "images/icon/message.png",
"selectedIconPath": "images/icon/message.png"
},{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "/images/icon/home.png",
"selectedIconPath": "/images/icon/home.png"
},
{
"pagePath": "pages/my/my",
"text": "我",
"iconPath": "/images/icon/my.png",
"selectedIconPath": "/images/icon/my.png"
}
]
}

改完一运行,发现“消息”栏虽然显示在第一个了,但是默认选中的还是“首页”…

研究了一下,发现如果想修改默认选中的tab,只需要修改”pages”数组里的顺序即可,放在前面的会优先选中。
所以,此处应该这么改:

"pages": [
"pages/message/message",
"pages/index/index",
"pages/my/my"
],

OK,就这样搞定了!