以下内容仅是个人项目总结。
1、create
(1)resizepage;
(2)修改echarts的默认字体;
(3)clearTimer;
(4)initData;
2、mounted
that.$nextTick(() => {
//1、重构页面宽高
//2、wow初始化
//3、初始化chart(initChart)
//4、添加定时等内容
this.timerObject.timer1 = xxx;
})
4.methods: {
initData(){
},
initChart() {
const that = this
if (this.chartObj.chart1 == null) {
this.chartObj.chart1 = echarts.init(this.$refs.chart1)
}
that.chart1()
window.addEventListener('resize', function() {
// that.$router.go(0) 强制刷新页面
that.chartObj.chart1.resize()
})
},
clearTimer(){
window.clearInterval(this.timerObject.timer1)
}
chearChart(){
if (this.chartObj.chart1 != null) {
this.chartObj.chart1.clear()
}
}
}
5、beforeDestory(){
this.clearTimer()
this.clearChart()
}