From 6d4c2422ed203cc8a3c8cd70df3070ab29908a51 Mon Sep 17 00:00:00 2001 From: official_dulin Date: Fri, 13 Oct 2023 15:56:30 +0800 Subject: [PATCH] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 343c02d..cba2c0c 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,24 @@ const echartInstance = this.echartRef.getEchartsInstance(); const base64 = echartInstance.getDataURL(); ``` +TypeScript and `useRef()` example: + +```ts +const getOption = () => {/** */} +export default function App() { + const echartsRef = useRef>(null); + + useEffect(() => { + if (echartsRef.current) { + const echartsInstance = echartsRef.current.getEchartsInstance(); + // do something + echartsInstance.resize(); + } + }, []); + return ; +} +``` + **About API of echarts, can see** [https://echarts.apache.org/api.html#echartsInstance](https://echarts.apache.org/api.html#echartsInstance). You can use the API to do: