问题描述
我在读取 JSON 文件后立即在 Chrome 中收到此错误.它可以在 Safari 和 Firefox 中正常运行.
I get this error in Chrome immediately after reading a JSON file. It works correctly in Safari and Firefox.
console.log ("事件 -> "+ postcards.nodes[0].node.event);//Safari 中的 "tally" "TypeError: Cannot read property 'node' of undefined" 在 Chrome 中.<
console.log ("event -> "+ postcards.nodes[0].node.event); // "tally" in Safari "TypeError: Cannot read property 'node' of undefined" in Chrome.<
嵌套 JSON 文件中的级别是否有限制?我从 Drupal 视图生成 JSON.这里是开始:
Is there a limit to the levels in a nested JSON file? I generate the JSON from a Drupal view. Here here is the start:
{"nodes":[{"node":{"w1":"","w2":"1","w3":"","w4":"", ...<
这里是 Javascript:
Here is the Javascript:
d3.json(
"/sites/default/d3_files/json/toronto-wards.json",
function(error,wards) {
d3.json("/postcards-json", function(error, postcards) {
console.log ("event -> "+ postcards.nodes[0].node.event); // tally in Safari
我正在使用 macOS,而我的朋友使用 Windows 在 Firefox 中遇到了同样的错误.
I'm using macOS and my friends using Windows get the same error in Firefox.
根据要求,我认为这是 XHR 消息:
As per request here is what I think is the XHR message:
d3.min.js:1 XHR finished loading: GET "http://www.stopplastics.ca/postcards-json".
推荐答案
问题是由于 Drupal 视图没有正确创建造成的.与 Chrome 浏览器无关.
The problem was caused by the Drupal view not being created correctly. Nothing to do with the Chrome browser.
这篇关于在某些(不是全部)浏览器中读取 D3 javascript 中的 JSON 文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!