【发布时间】:2021-05-29 20:07:21
【问题描述】:
有没有办法将链接附加到 3d-force-graph (https://github.com/vasturiano/3d-force-graph) 中的节点,这样如果用户点击一个节点,他们就会被带到一个特定(或自定义)的 url?
【问题讨论】:
标签: javascript three.js 3d
有没有办法将链接附加到 3d-force-graph (https://github.com/vasturiano/3d-force-graph) 中的节点,这样如果用户点击一个节点,他们就会被带到一个特定(或自定义)的 url?
【问题讨论】:
标签: javascript three.js 3d
答案在.onNodeClick 函数中找到。例如,为您的 json 添加一个链接:
'nodes': [
{
"id": "id1",
"name": "<h2>Title 1</h2>",
"val": 1,
'link': 'test.html?id=1',
},
并将以下内容添加到您的图形对象中:
.onNodeClick(function(node){
window.location.href = node.link;
})
【讨论】: