ecomfe / echarts-gl

Extension pack for Apache ECharts, providing globe visualization and 3D plots.
BSD 3-Clause "New" or "Revised" License
2.59k stars 844 forks source link

NuxtJs使用时,提示【self is not defined】 #510

Open ColaYuan opened 11 months ago

ColaYuan commented 11 months ago

image

sinedie commented 8 months ago

When using echarts-gl, (in nextjs), need to import dymamicly.

I use a single file with a chart-utility-component and imports this file dynamicly at runtime.

Inside this file, imports of echarts-gl are as the docs says.

import * as echarts from 'echarts';
import 'echarts-gl';
...

export default function Echart({mergeOptions, options, width, hegiht, onInit}) {
 // here initialize the charts and handle all update chart logic
}
const Echart = dynamic(() => import('@/components/plots/Echart'), {
  loading: () => <Loading />,
  ssr: false,
});
...

<Echart ... />

This is in react, not vue but maybe vue has a similar capability