在使用vue绘图的时候,我设置间隔时间进行绘制,控制台一直警告 [ECharts] There is a chart instance already initialized on the dom.
查看代码是因为获取了两次dom进行了初始化
mounted() {
this.mychart = echarts.init(this.$refs.charts);//此处和下边的initChart方法里重复了
//实时获取,离开销毁
let currentTimer = setInterval(() => {
console.log(this.maxList)
this.getByIdMax();
}, 1000);
this.$once("hook:beforeDestroy", () => {
clearInterval(currentTimer);
currentTimer = null;
console.log("高温预警卡片销毁了");
});
},
methods: {
//图表初始化
initChart() {
//初始化echarts实例(与上方重复获取dom导致出错,删掉即可)
let lineCharts = echarts.init(this.$refs.charts);