D3.js 从 file:///加载本地数据文件 [英] D3.js loading local data file from file:///
问题描述
我知道 D3.js 支持使用 XHR 和 JSONP 请求加载数据文件.
I know that D3.js supports loading data files with XHR and JSONP requests.
但是在我的情况下,我将通过从文件系统双击它们来运行 .html 文件,这将像 file://.../foo.html
一样运行浏览器.
However in my case, I am going to run .html files by double clicking on them from filesystem, which is going to run it like file://.../foo.html
on browser.
是否可以从计算机加载与浏览器上的 foo.html
相同目录中的数据文件(csv 或 json)(而不是在 http://
上运行)但是 file://
)?
Is it possible to load data file (csv or json) within the same directory from computer as foo.html
on browser (while not running on http://
but file://
)?
推荐答案
您可以通过禁用浏览器中的相应安全机制.我认为它默认适用于 Opera,您可以使用 --allow-file-access-from-files
命令行标志启动 Chrome,以允许从 file://<加载数据/代码>.
You can by disabling the respective security mechanisms in your browser. I think it works in Opera by default, and you can start Chrome with the --allow-file-access-from-files
command line flag to allow loading data from file://
.
这篇关于D3.js 从 file:///加载本地数据文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!