本文简单记录了项目中在React和Vue中引入mxGraph。请搜索mxGraph是什么。下面是React中引入的mxGraphmxgraph-typeings涉及的仓库地址下面是引入ES6基本写法的例子:importReact,{useCallback}from'react'import'mxgraph/javascript/src/css/common.css'import'style.css'constmx=require('mxgraph')({mxBasePath:'mxgraph'})const{mxGraph}=mxfunctionApp(){letgraph=nullconstcontainerRef=useCallback(node=>{if(node!=null){initGraph(node)constparent=graph.getDefaultParent()graph.getModel().beginUpdate()try{constv1=graph.insertVertex(parent,null,'vertex1',0,0,80,20)constv2=graph.insertVertex(parent,null,'vertex2',100,0,80,20)graph.insertEdge(parent,null,'',v1,v2)}最后{graph.getModel().endUpdate();}}},[])函数initGraph(container){graph=newmxGraph(container)}return(
