在 Vue 项目中使用 ECharts 时,一开始图表能渲染出来,当切换到其他页面再回来的时候,图表就会不显示。
// 清除Echarts默认添加的属性,重新setOption
function removeChartAttr(chartDom: any) {
try {
chartDom.removeAttribute('_echarts_instance_')
} catch (error) {
console.log(error)
}
}
其他类似问题:
选项卡中使用echart来回切换时不显示
使用 nextTick()
使用 setTimeout(() => {},500)