提交 595bb0bc authored 作者: tb53863844's avatar tb53863844

修改bug

上级 08439167
...@@ -2,8 +2,10 @@ import React from 'react' ...@@ -2,8 +2,10 @@ import React from 'react'
import Neo4jD3 from '@/webPublic/one_stop_public/utils/Neo4jD3' import Neo4jD3 from '@/webPublic/one_stop_public/utils/Neo4jD3'
import UUID from 'react-native-uuid'; import UUID from 'react-native-uuid';
export default class Neo4jD3Com extends React.Component { export default class Neo4jD3Com extends React.Component {
state={
uid:UUID.v4()
}
uid=UUID.v4()
triggerChange = (changedValue) => { triggerChange = (changedValue) => {
...@@ -14,24 +16,57 @@ export default class Neo4jD3Com extends React.Component { ...@@ -14,24 +16,57 @@ export default class Neo4jD3Com extends React.Component {
} }
} }
data data
q
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// Should be a controlled component.
if ('option' in nextProps&&nextProps.option&&nextProps.option.neo4jData) { if ('option' in nextProps&&nextProps.option&&nextProps.option.neo4jData) {
if(this.neo4jd3==null){ if(this.neo4jd3==null){
this.data=nextProps.option.neo4jData
this.init(nextProps.option.neo4jData) this.q=nextProps.option.q
this.neo4jd3=this.init(nextProps.option.neo4jData)
}else{ }else{
if(JSON.stringify(this.data)!=JSON.stringify(nextProps.option.neo4jData)){ if(this.q!=nextProps.option.q){
this.neo4jd3.updateWithD3Data(nextProps.option.neo4jData) const newuid=UUID.v4()
this.data=nextProps.option.neo4jData this.q=nextProps.option.q
this.setState({uid:UUID.v4()},()=>{
this.init(nextProps.option.neo4jData,newuid)
})
}
}
} }
} }
/* componentWillReceiveProps(nextProps) {
// Should be a controlled component.
if ('option' in nextProps&&nextProps.option&&nextProps.option.neo4jData) {
if(this.neo4jd3==null){
this.q=nextProps.option.q
this.neo4jd3=this.init(nextProps.option.neo4jData,this.uid)
}else{
if(this.q!=nextProps.option.q){
const newuid=UUID.v4()
this.neo4jd3.clear()
var test=document.createElement('div');
test.setAttribute("id","id_"+newuid);
test.setAttribute("key",newuid);
console.log(document.getElementById("zhishi"));
document.getElementById("zhishi").append(test)
this.neo4jd3=this.init(nextProps.option.neo4jData,newuid)
this.q=nextProps.option.q
} }
} }
}
}
*/
changePos=(obj)=>{ changePos=(obj)=>{
...@@ -44,7 +79,7 @@ export default class Neo4jD3Com extends React.Component { ...@@ -44,7 +79,7 @@ export default class Neo4jD3Com extends React.Component {
neo4jd3 neo4jd3
init=(neo4jData)=>{ init=(neo4jData)=>{
this.neo4jd3 = new Neo4jD3 ('#id_'+this.uid, { return new Neo4jD3 ('#id_'+this.state.uid, {
highlight: [ highlight: [
{ {
class: 'Project', class: 'Project',
...@@ -132,7 +167,9 @@ export default class Neo4jD3Com extends React.Component { ...@@ -132,7 +167,9 @@ export default class Neo4jD3Com extends React.Component {
render() { render() {
return ( return (
<div id={"id_"+this.uid} style={{height:500}}></div> <div id="zhishi">
<div id={"id_"+this.state.uid} style={{height:500}}> </div>
</div>
); );
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论