对于小程序中的每个页面,都需要在页面对应的 js
文件中调用 Page
方法注册页面示例,指定页面的初始数据、生命周期回调、事件处理函数等。详细请看官方:https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html
其中页面事件中有onTabItemTap事件,表示点击tab时触发此事件,但是必须保证当前页是tabbar页面
Page({
onTabItemTap(item) {
// 可以在此做自己需求的逻辑操作,如点击出现弹窗等
wx.showActionSheet({
itemList:['1','2'],
success(res){
console.log(res.tapIndex)
}
})
console.log(item.index)
console.log(item.pagePath)
console.log(item.text)
}
})