var themeMod = require('../utils/theme') Component({ data: { selected: 0, themeStyle: '' }, lifetimes: { attached: function () { var theme = themeMod.getCurrentTheme() this.setData({ themeStyle: themeMod.getThemeStyle(theme) }) } }, pageLifetimes: { show: function () { var theme = themeMod.getCurrentTheme() this.setData({ themeStyle: themeMod.getThemeStyle(theme) }) } }, methods: { switchTab: function (e) { var index = e.currentTarget.dataset.index var pages = [ '/pages/index/index', '/pages/records/records', '/pages/settings/settings' ] if (index === this.data.selected) return wx.switchTab({ url: pages[index] }) } } })