The components of echarts in vue3 are not displayed after switching

Phenomenon: When the page is refreshed, echarts is displayed normally, but when the component is switched, the echarts chart is invisible
Reason: when leaving the current page, the echarts instance is not destroyed, and when entering the page again, it will not be triggered Update
solution: Destroy the echarts instance in the onBeforeUnmount life cycle

onBeforeUnmount(() => {
    
    
  myChart.dispose();
  ticketsChart.dispose();
});

Guess you like

Origin blog.csdn.net/lfwoman/article/details/120205440