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);