| | |
| | | import React, { useRef, useEffect } from "react"; |
| | | import React, { useRef, useEffect, useState } from "react"; |
| | | import { Button } from 'antd'; |
| | | |
| | | export const GraphTools = ({ graphRef,isReady }) => { |
| | | export const GraphTools = ({ graphRef, isReady }) => { |
| | | |
| | | const exportData = () => { |
| | | const graph = graphRef.current; |
| | | if (graph) { |
| | | if (isReady) { |
| | | const data = graph.toJSON(); |
| | | console.log(data); |
| | | // 这里你可以将数据发送到服务器或保存到本地 |
| | | } |
| | | } |
| | | |
| | | return <button onClick={exportData}>导出数据</button>; |
| | | return ( |
| | | <> |
| | | <Button type="primary" onClick={exportData}> |
| | | 导出数据 |
| | | </Button> |
| | | </> |
| | | ); |
| | | } |