react中封装Echarts组件三种写法
第一种:使用类组件
import React, {
Component } from 'react';
import echarts from 'echarts';
import {
Map } from 'immutable'
class Echart extends Component {
myChart = null;
resizeEcharts = () => {
this.myChart && this.myChart.resize();
};
setEchartOptions = () => {
this.myChart.setOption(this.props.options);
};
componentDidMount() {
this.myChart = echarts.init(this.chartRef);
window.addEventListener('resize', this.resizeEcharts);
}
componentDidUpdate(preProps){
const isEqual = Map(this.props.options<

最低0.47元/天 解锁文章
1131

被折叠的 条评论
为什么被折叠?



