【发布时间】:2020-08-16 04:21:09
【问题描述】:
我是 javascript 和 Web 开发的新手,但我正在尝试从我的桌面学习使用 d3 一个 csv 文件。我的代码如下:
<!DOCTYPE html>
<html lang = "en">
<head>
<script src = "https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<script>
d3.csv("csv_file.csv", function(data){
console.log(data);
});
</script>
</body>
</html>
但是,我收到错误消息:
Access to XMLHttpRequest at 'file:///Users/Desktop/College_Finder/csv_file.csv' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
index.html:10 null
我不知道这意味着什么或如何解决它
【问题讨论】:
-
我不确定,但有人问过类似的问题here。
标签: javascript html d3.js xmlhttprequest