在根项目(和main.js、pages.json等文件同级的地方)中创建微信小程序原生的 custom-tab-bar 文件,
可以微信小程序参考官方
https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html
这里要注意的是
this.getTabBar().setData({
selected: 0
})
这种写法是在微信小程序原生中用的(微信小程序原生的.js中使用),
在uniapp中,应该如下使用,否者每次跳转tab页,都是第一个被选中
// 更新自定义 TabBar 选中状态(.vue中使用)
if (typeof this.$mp.page.getTabBar === 'function') {
const tabBar = this.$mp.page.getTabBar();
if (tabBar) {
tabBar.setData({
selected: 0
});
}
}
1***@qq.com
- 发布:2026-04-03 19:59
- 更新:2026-04-03 19:59
- 阅读:15
0 个评论
要回复文章请先登录或注册