vue3使用ECharts 踩坑记录:一旦触发 resize
方法就报错Cannot read property 'type' of undefined
的解决方案
最近在项目中使用 ECharts 图表时,遇到了一个让人抓狂的问题:图表初始渲染完全正常,但一旦触发 resize
方法,就会报错:Cannot read property 'type' of undefined
。调试了半天都找不到问题,最终才发现了解决方案。特此记录,分享给同样在用 Vue3 和 ECharts 的小伙伴们,希望能少踩坑。

问题复现
在 Vue3 项目中,我尝试这样使用 ECharts: