【问题标题】:D3: "Invalid argument" error using d3.js in IE9D3:在 IE9 中使用 d3.js 时出现“无效参数”错误
【发布时间】:2013-10-08 06:13:27
【问题描述】:

我正在尝试使用 d3.v3.js、world-110m.json 和 topojson.v1.js 让地图在 IE9 中工作(我也在使用 jQuery 10.1,所以它也被加载了)。它在 FF 和 Chrome 中运行良好,但据我所知,IE 8 及更低版本没有原生 SVG 支持,因此如果没有解决方法就无法支持。

不幸的是,IE9 似乎也无法正常工作。 IE 9 控制台报错:

SCRIPT87:参数无效。 d3.v3.js,第 726 行字符 4

    d3_selectionPrototype.insert = function(name, before) {
        name = d3_selection_creator(name);
        before = d3_selection_selector(before);
        return this.select(function() {
          return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments));
        });
    };

第 726 行是“return this.insertBefore”等。任何想法发生了什么以及如何解决?

【问题讨论】:

  • FWIW:我发现这个错误是在 d3 版本中引入的。 3.2.3(现在是 3.3.6)。我就此事联系了 Mike Bostock。他对 d3.v3 进行了轻微编辑,消除了这个错误。第 777 行:返回 this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null);

标签: javascript jquery internet-explorer svg d3.js


【解决方案1】:

IE9 实现 insertBefore 的方式与其他浏览器不同。 this question 的答案中的更多细节我怀疑在你的情况下第二个参数是空的。

【讨论】:

  • 感谢您的指导。可悲的是,这是在应该处理 d3.v3 的 IE9 中抛出的
猜你喜欢
  • 2014-05-04
  • 2017-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-11
  • 1970-01-01
相关资源
最近更新 更多