最简单的D3.js示例不工作 [英] Simplest D3.js example not working

查看:163
本文介绍了最简单的D3.js示例不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 index.html 文件中有这个,但它不显示我想用 D3

I have this in my index.html file but it does not show the paragraph that I want to add with D3

<!DOCTYPE html>
<html>
  <head>
    <title> D3 page template </title>
    <script type="text/javascript" src = "d3/d3.v3.js"></script> 
  </head>

  <body>
    <script type="text/javascript">
        d3.select("body").append("p").text("new paragraph!");
    </script>
  </body>
</html>

我参考的路径 D3.js 应该是正确的,因为如果我在浏览器中做一个检查元素,我可以点击 D3 链接,它需要我的源代码。

The path to where I am referencing D3.js should be correct because if I do an inspect element in the browser I can click on the D3 link and it takes me to its source code.

推荐答案

您的HTML页面中缺少字符集。添加如下内容:

You are missing the character set in your HTML page. Add something like this:

<meta charset="utf-8">

D3的未缩减源包括pi的实际符号,如果字符set未定义。

The un-minified source of D3 includes the actual symbol for pi, which confuses the browser if the character set is not defined.

这篇关于最简单的D3.js示例不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆