0
在下面的代码,我的一个节点添加到setTimout
图,但它不是渲染。当我将代码移出setTimeout
时,它被绘制出来。任何原因 ?Cytoscape的:在setTimeout的添加元素不会被渲染
var cytoscape = require('cytoscape');
var cy = cytoscape({
container: document.getElementById('container'),
layout: {
name: 'circle'
}
});
cy.add({
group: "nodes",
data: {
id: 'id1'
}
}
); // this adding is drawn
console.log(cy.nodes()); // this shows that the node with id:id1 is added
setTimeout(function() {
cy.add({
group: "nodes",
data: {
id: 'id2'
}
}
); // this one doesn't get drawn
console.log(cy.nodes()); // BUT, this shows that the node with id:id2 is added
}, 500);