Echarts draws a histogram and reports an error "Initialize failed: invalid dom."

reason:

When echarts creates a chart, it needs a div as a dom container, and then mounts the map initialized by an echarts instance initialized by the echarts.init  method into the dom tree.

<div id="map" v-if="showType != 'list'"></div>

And this error means that before the element is created, go to getElement to get the element.

solve:

I thought it was a problem with the life cycle. After changing it for a long time, I found out that a v-if was hung on the dom container, and the v-if was controlled by the data obtained by adjusting the back-end interface later. As a result, before the data was obtained, The div is removed from the dom tree by v-if, just change it to v-show

Finally, it can be successfully rendered

 

Guess you like

Origin blog.csdn.net/m0_46550764/article/details/121410220