【问题标题】:SVG numberOfItems property not workingSVG numberOfItems 属性不起作用
【发布时间】:2016-02-02 23:57:08
【问题描述】:

在最新更新后,我们的网站突然停止在 Chrome(只是 chrome)上运行......

给出的错误是

Uncaught TypeError: Cannot read property 'numberOfItems' of undefined

这是使用 numberOfItems 属性的地方:

// Absolutize and parse path to array
  , parse: function(array) {
      /* if it's already is a patharray, no need to parse it */
      if (array instanceof SVG.PathArray) return array.valueOf()

      /* prepare for parsing */
      var i, il, x0, y0, x1, y1, x2, y2, s, seg, segs
        , x = 0
        , y = 0

      /* populate working path */
      SVG.parser.path.setAttribute('d', typeof array === 'string' ? array : arrayToString(array))

      /* get segments */
      segs = SVG.parser.path.pathSegList


      for (i = 0, il = segs.numberOfItems; i < il; ++i) {
        seg = segs.getItem(i)
        s = seg.pathSegTypeAsLetter
etc. (I didn't put the whole loop)

为什么在最新的 Chrome 更新后 SVG 和 Javascript 无法读取此属性?有什么好的解决办法?

谢谢!!

【问题讨论】:

标签: javascript google-chrome svg


【解决方案1】:

【讨论】:

  • 非常感谢!我只有一个小问题......我正在尝试做 polyfill,但我仍然得到错误。这是我的项目:github.com/jeratt/Citywide-Dashboard 我已经将 "" 粘贴到 index.php 并将 pathseg.js 文件添加到主目录(以及尝试一堆其他子文件夹。我做错了什么?谢谢!
猜你喜欢
  • 2014-05-05
  • 1970-01-01
  • 2014-12-21
  • 2021-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-31
  • 2018-03-15
相关资源
最近更新 更多