提交 6ac72966 编写于 作者: L lin-xin

'离开首页时移动监听事件'

上级 8b9aca06
...@@ -180,8 +180,7 @@ ...@@ -180,8 +180,7 @@
bgColor: '#F5F8FD', bgColor: '#F5F8FD',
bottomPadding: 30, bottomPadding: 30,
topPadding: 30 topPadding: 30
}, }
collapse: false
} }
}, },
components: { components: {
...@@ -193,23 +192,15 @@ ...@@ -193,23 +192,15 @@
} }
}, },
created(){ created(){
bus.$on('collapse', msg => { this.handleListener();
this.collapse = msg;
});
// 调用renderChart方法对图表进行重新渲染
window.addEventListener('resize', ()=>{
this.$refs.bar.renderChart();
this.$refs.line.renderChart();
})
this.changeDate(); this.changeDate();
}, },
watch: { activated(){
collapse(){ this.handleListener();
setTimeout(() => { },
this.$refs.bar.renderChart(); deactivated(){
this.$refs.line.renderChart(); window.removeEventListener('resize', this.renderChart);
}, 300); bus.$off('collapse', this.handleBus);
}
}, },
methods: { methods: {
changeDate(){ changeDate(){
...@@ -218,6 +209,20 @@ ...@@ -218,6 +209,20 @@
const date = new Date(now - (6 - index) * 86400000); const date = new Date(now - (6 - index) * 86400000);
item.name = `${date.getFullYear()}/${date.getMonth()+1}/${date.getDate()}` item.name = `${date.getFullYear()}/${date.getMonth()+1}/${date.getDate()}`
}) })
},
handleListener(){
bus.$on('collapse', this.handleBus);
// 调用renderChart方法对图表进行重新渲染
window.addEventListener('resize', this.renderChart)
},
handleBus(msg){
setTimeout(() => {
this.renderChart()
}, 300);
},
renderChart(){
this.$refs.bar.renderChart();
this.$refs.line.renderChart();
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册