【问题标题】:Attach link to 3d-force-graph node将链接附加到 3d-force-graph 节点
【发布时间】:2021-05-29 20:07:21
【问题描述】:

有没有办法将链接附加到 3d-force-graph (https://github.com/vasturiano/3d-force-graph) 中的节点,这样如果用户点击一个节点,他们就会被带到一个特定(或自定义)的 url?

【问题讨论】:

    标签: javascript three.js 3d


    【解决方案1】:

    答案在.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;
    })
    

    【讨论】:

      猜你喜欢
      • 2013-04-27
      • 1970-01-01
      • 2022-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多