我为某些节点设置了href,它可以正常工作,但其他节点打开空白页面,是否可以使它们没有href且不打开空白页面?
我用它来制作href:
cy.nodes('[id = "start"]').data('href', 'https://js.cytoscape.org/');
cy.on('tap', 'node', function () {
try {
window.open(this.data('href'));
} catch (e) {
window.location.href = this.data('href');
}
});
是,监听来自node[href]
的事件,这意味着在其数据集中包含href
的节点。
cy.on('tap', 'node[href]', function() {})
我对此不太确定,但是应该可以。如果没有,只需添加
if (!this.data('href')) return;
作为处理程序的第一行。