赞
踩
onChange(event) {
this.setData({
active: event.detail,
});
wx.switchTab({
url: this.data.list[event.detail].url,
});
},
init() {
const page = getCurrentPages().pop();
this.setData({
active: this.data.list.findIndex(item => item.url === `/${page.route}`)
})
}
在对应的使用tabbar页面编写
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 通过 getTabBar 接口获取组件实例,并调用 setData 更新选中态
this.getTabBar().setData({active: 0})
},
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。