Null pointer problem occurred in Echarts dynamic add and delete chart.

I am using vue+echart, and the chart for echart operation is encapsulated in a component of vue.

when leaving this component, because DOM is replaced, the referenced diagram naturally becomes null:
Cannot read property "getAttribute" of null

the way I think of is to release resources with dispose when leaving the component:

//
echarts.dispose(chartEle);
chartEle.dispose

I hope you will come up with some ideas.

Apr.20,2022

wouldn't it be bigger to repackage something as big as echarts? It is better to give an interface variable directly. Echarts is easy to operate in the global variable. If it is destroyed, it will destroy


thought. There is a problem with your implementation

.
Menu