共计 313 个字符,预计需要花费 1 分钟才能阅读完成。
报错:已存在图表,渲染重复
解决: 在合适的时机执行 dispose 方法即可
// echarts 全局存入 实例
let myChart: any;
// 在你的 initChart 初始化 Echarts 方法中 先执行清理方法
const initChart = () => {
// 执行清理方法然后初始化
if(myChart){console.log('存在则清空')
myChart.dispose();}
// 暂存 Echarts 实例
myChart = echarts.init(chartRef.value);
}
原文地址: [ECharts] There is a chart instance already initialized on the dom. 已存在图表,渲染重复
正文完