【问题标题】:d3.js 404 json file not foundd3.js 404 json 文件未找到
【发布时间】:2018-10-27 05:00:43
【问题描述】:

我在这里尝试使用 d3.js 示例代码:https://bl.ocks.org/ChumaA/385a269db46ae56444772b62f1ae82bf

在这种情况下,我使用 view jam/express/node 来加载它,但是我收到 mockelasticdata.json 文件的 404 错误,我相信我正确地路由它。我提供了照片来显示目录路径和 chrome 控制台错误。

控制台错误:

目录路径:

编辑:这是使用 d3 读取数据的 json 调用

      d3.json('src/mockelasticdata.json', function(error, mockdata) {
          if (error) return console.error(error);
          console.log('mockdata',mockdata);
          mapdata = mockdata;
          draw(mockdata)
      });

【问题讨论】:

标签: javascript node.js d3.js http-status-code-404


【解决方案1】:

您正在尝试访问 src 目录中的文件。构建并运行项目后,该目录不存在。

将 JSON 文件移动到公共目录中。这是提供所有静态、未路由文件的地方。

【讨论】:

    猜你喜欢
    • 2016-09-12
    • 2014-11-10
    • 1970-01-01
    • 1970-01-01
    • 2020-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-22
    相关资源
    最近更新 更多