javascript 未捕获的 ReferenceError:d3 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25291823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 04:18:11  来源:igfitidea点击:

Uncaught ReferenceError: d3 is not defined

javascriptd3.js

提问by aschaefer

I am new to web development and I am trying to upload a D3-based JS visualization to a Weebly domain. I have uploaded all required files to my Weebly site and referenced them properly in the JavaScript, but keep getting an Uncaught ReferenceError: d3 is not defined error on this line:

我是 Web 开发的新手,我正在尝试将基于 D3 的 JS 可视化上传到 Weebly 域。我已将所有必需的文件上传到我的 Weebly 站点并在 JavaScript 中正确引用它们,但不断收到 Uncaught ReferenceError: d3 is not defined 错误在这一行:

d3.csv("http://subdomain.weebly.com/files/theme/force.csv", function(error, links) {

Where I try to call d3 to load in a CSV file for my visualization. I can't seem to find out what the problem is.

我尝试调用 d3 加载 CSV 文件以进行可视化。我似乎无法找出问题所在。

Also, I loaded d3 (hosted locally) into the JS with this line:

另外,我使用以下行将 d3(本地托管)加载到 JS 中:

<script src="http://subdomain.weebly.com/files/theme/d3.js" charset="utf-8"></script>

and also tried to link to d3 remotely, but still get the same error.

并尝试远程链接到 d3,但仍然出现相同的错误。

This has me very confused because everything works fine on my localhost.

这让我很困惑,因为在我的本地主机上一切正常。

Thanks!

谢谢!

回答by lhoworko

insert the following into your html

将以下内容插入您的 html

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>

回答by Yash

I had a similar issue. It got solved after I replaced the link I was using with the one said above by @Ihoworko which is this

我有一个类似的问题。在我用@Ihoworko 上面所说的链接替换了我正在使用的链接后,它得到了解决,就是这个