有什么方法可以将getorgchart与reactjs集成/使用,因为我想将它包含在我的react js应用程序中。我已经尝试过下面的代码(即在reactjs组件中渲染getorgchart html代码)但它不起作用并且有语法错误所以请帮我用 reactjs 设置它。
import React, { Component } from 'react';
import { BrowserRouter as Router, Switch, Route, Link } from 'react- router-dom';
class Chart extends React.Component {
constructor (props) {
super(props)
this.state = {
};
}
render() {
return (
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://balkangraph.com/js/latest/orgchart.js"></script>
</head>
<body>
<div id="orgchart">
</div>
<script>
var chart = new OrgChart(document.getElementById("orgchart"), {
theme:"planner", //getting error on ':' colon
enableEdit: false,
enableZoom:false,
enableSearch: false,
enableMove: true,
enableDetailsView: false,
nodeMenu:{
details: {text:"Details"},
edit: {text:"Edit"},
add: {text:"Add"},
remove: {text:"Remove"}
},
nodeBinding: {
field_0: "name"
},
nodes: [
{ id: 1, name: "Amber McKenzie"},
{ id: 2, pid: 1, name: "Ava Field" },
{ id: 3, pid: 1, name: "Peter Stevens" }
]
});
</script>
</body>
</html>
);
}
}
export default Chart;