在下面的代码中,我向图中添加了一个节点,setTimout
但它没有被渲染。当我将代码移出时,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);