gpt4 book ai didi

javascript - D3.js: "Uncaught SyntaxError: Unexpected token ILLEGAL"?

转载 作者:IT王子 更新时间:2023-10-29 02:48:50 29 4
gpt4 key购买 nike

我刚刚 downloaded D3.js from d3js.org (链接到 zip 文件),将其解压缩并在以下 HTML 页面中引用它:

<html>
<head>
<title>D3 Sandbox</title>
<style>
</head>
<body>
<script src="/d3.v3.js"></script>
</body>
</html>

但是当我加载这个页面时,我的控制台(在 Chrome 中)给我这个错误:

Uncaught SyntaxError: Unexpected token ILLEGAL: line 2

它不喜欢 pi and e symbols at the start of the file . Errrr...我该怎么办?我正在使用 Python 的 SimpleHTTPServer 提供文件。

更新:是的,我知道我可以只链接到 CDN 版本,但我更愿意在本地提供文件。

最佳答案

尝试在 HTML 主机文档上指定 UTF-8 字符集:

<meta http-equiv="content-type" content="text/html; charset=UTF8">

D3 包含在非 UTF8 文档中无效的 UTF-8 符号(如 π)。

关于javascript - D3.js: "Uncaught SyntaxError: Unexpected token ILLEGAL"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15237073/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com