123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- const app = getApp()
- Component({
- /**
- * 组件的属性列表
- */
- properties: {},
- /**
- * 组件的初始数据
- */
- data: {
- active: 'pages/home/home',
- list: app.globalData.tabBarList
- },
- lifetimes: {
- attached() {
- this.setData({
- list: app.globalData.tabBarList
- })
- app.addTabBarList = res => {
- this.setData({
- list: res
- })
- }
- }
- },
- /**
- * 组件的方法列表
- */
- methods: {
- onChange(e) {
- const detail = e.detail
- const page = getCurrentPages()
- if (page[page.length - 1].route !== detail) {
- wx.switchTab({
- url: `/${detail}`
- })
- if (detail === 'pages/mine/mine') {
- app.fetchUserData()
- }
- }
- this.setData({
- active: detail
- })
- },
- init() {
- const page = getCurrentPages().pop()
- this.setData({
- active: `${page.route}`
- })
- }
- }
- })
|