在init方法前,添加如下代码:
var myChart = null;
if (myChart && myChart.dispose) { myChart.dispose(); } myChart = echarts.init(document.getElementById("main"));