Use Hooks + typescript + ReactEcharts 中关于数据渲染跳动 以及一些隐藏的坑
首先说如何使用 个人的使用方法是
import { EChartsOption } from "echarts";
import ReactEcharts from "echarts-for-react";
import React, { useEffect, useMemo, useState } from "react";
需要引入的组件,下面是用的官网的简单柱状图
const getOption = () => {
console.log("getoption被调用")
const options: EChartsOption = {
title: {
text: "标题",
},
xAxis: {
type: "category",
data: [自定义数据],
},
yAxis: {
type: "value",
},
series: [
{
data: [自定义数据],
type: "bar",
},
],
tooltip: {
transitionDuration: 0,
},
};
return options;
};
注册组件
<ReactEcharts
style={
{ background: "#fff", height: "376px", width: "100%" }