- 如果需要在点击tabBar项后做其它的处理,可以监听tabitembtn事件进行处理,监听点击事件后tabBar将不会自动切换页面,需要调用setTabBarAttr方法进行切换。
function apiready(){
api.addEventListener({
name:'tabitembtn'
}, function(ret) {
console.log('点击了第'+(ret.index+1)+'项');
api.setTabBarAttr({
index: ret.index
});
});
}
- 打开tabBar后,可以为tabBar上面的各项设置角标,如:
function setTabBarItemDot(){
api.setTabBarItemAttr({
index: 2,
badge: {
text: '',
radius: 5,
x: 8
}
});
}