12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import TabMenu from './tabsets'
- Component({
- data: {
- active: 0,
- list: TabMenu,
- theme: {
- custom: {
- colorPrimary: '#eda92a',
- },
- },
- height: 0,
- },
- lifetimes: {
- // attached() {
- // wx.createSelectorQuery()
- // .in(this)
- // .select('.t-tab-bar')
- // .boundingClientRect((rect) => {
- // if (rect) {
- // console.log(rect)
- // this.setData({
- // height: rect.height,
- // })
- // }
- // })
- // .exec()
- // },
- },
- methods: {
- onChange(event: WechatMiniprogram.CustomEvent<{ value: string }>) {
- const { value } = event.detail
- wx.switchTab({
- url: (value.startsWith('/') ? '' : '/') + value,
- })
- },
- init(func: Function | null = null) {
- const page = getCurrentPages().pop()
- const route = page ? page.route.split('?')[0] : ''
- const active = this.data.list.findIndex(
- (item) =>
- (item.pagePath.startsWith('/') ? item.pagePath.substr(1) : item.pagePath) === `${route}`,
- )
- this.setData({ active }, () => {
- func && func()
- })
- },
- },
- })
|