diff --git a/src/views/home/Index.vue b/src/views/home/Index.vue index ff67183..34edc50 100644 --- a/src/views/home/Index.vue +++ b/src/views/home/Index.vue @@ -40,9 +40,16 @@ export default { } }, created () { + console.log('created....') this.getInfo() + // 监听是否切换了日,周,月,年 + this.eventBus.$on('updateHomeDataByType', (type) => { + console.log(type) + this.getInfo() + }) }, - mounted () { + destroyed () { + this.eventBus.$off('updateHomeDataByType') }, methods: { getInfo () { diff --git a/src/views/home/components/Count.vue b/src/views/home/components/Count.vue index 475f10b..d38d0b4 100644 --- a/src/views/home/components/Count.vue +++ b/src/views/home/components/Count.vue @@ -104,19 +104,19 @@ - + - + - + - + - + @@ -228,15 +228,12 @@ export default { { key: 'year', title: '本年' } ] }), - beforeCreate () { - console.log('beforeCreate.......') - }, methods: { handleMenuClick (e) { this.typeIndex = this.searchs.findIndex(item => item.key === e.key) - console.log(e.key) this.visible = false this.type = e.key + this.eventBus.$emit('updateHomeDataByType', { type: e.key }) } } }