1. 安装依赖
npm install echarts
2. 完整代码
import React, { useEffect, useRef } from 'react';
import * as echarts from 'echarts';
export default () => {
const chartRef = useRef(null);
useEffect(() => {
const echartsForm = echarts.init(chartRef.current);
const options = {}; //配置
echartsForm.setOption(options);
}, [])
return <div ref={chartRef} style={{ height: 500, width: 500 }}/>
}