Initial commit
This commit is contained in:
34
miniprogram/custom-tab-bar/index.ts
Normal file
34
miniprogram/custom-tab-bar/index.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
Component({
|
||||
data: {
|
||||
selected: 0,
|
||||
unreadCount: 0,
|
||||
tabs: [
|
||||
{ pagePath: '/pages/feed/feed' },
|
||||
{ pagePath: '/pages/nearby/nearby' },
|
||||
{ pagePath: '/pages/friends/friends' },
|
||||
{ pagePath: '/pages/profile/profile' },
|
||||
],
|
||||
},
|
||||
|
||||
methods: {
|
||||
onTab(e: WechatMiniprogram.CustomEvent) {
|
||||
const index = e.currentTarget.dataset.index as number
|
||||
const path = e.currentTarget.dataset.path as string
|
||||
if (index === this.data.selected) return
|
||||
this.setData({ selected: index })
|
||||
wx.switchTab({ url: path })
|
||||
},
|
||||
|
||||
onPost() {
|
||||
wx.navigateTo({ url: '/pages/post/post' })
|
||||
},
|
||||
|
||||
setSelected(index: number) {
|
||||
this.setData({ selected: index })
|
||||
},
|
||||
|
||||
setUnread(count: number) {
|
||||
this.setData({ unreadCount: count })
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user