vue echarts error: Cannot read property getAttribute of null

Reproduce the problem and explain the reasons:

The label with the div v-if: level === 2, level initial value is -1, mounted only after completion of the execution of a function assigned to the level, the value of level it may be true; while rendering the chart on in the next line of an assignment statement, echarts probably can not find dom node. Because when the condition is false, v-if not rendered conditional block, only when the condition is true, it began to render conditional block.

solve:

The v-if into a v-show, because no matter how the conditions of the true value, v-show elements always be rendered.

Do not render echarts false when the condition.

If you can, consider make initial conditional expression is true.

 

 v-if If the condition is false at the time of the initial rendering, rendering is not conditional block until the condition becomes true, it will begin to render conditional block.

Guess you like

Origin www.cnblogs.com/elegant-shao/p/12358388.html