【问题标题】:Using setAttribute with an array of Raphael paths将 setAttribute 与 Raphael 路径数组一起使用
【发布时间】:2010-09-28 21:53:44
【问题描述】:

当以下代码中的“事物”是路径数组时...

things.square = [ RM.path("m 154.21525,71.431259 74.32805,0 0,70.496711 -74.32805,0 0,-70.496711 z").attr(attr),
                  RM.path("m 271.25132,77.933263 58.07304,0 0,56.409037 -58.07304,0 0,-56.409037 z").attr(attr2)   ];

...那么这段代码不起作用:

    things.square[1].node.setAttribute("id","clicker");

即它未能将数组中的第二个路径分配给 id 'clicker'。但是,当“事物”只是一条路径时...

things.square = RM.path("m 154.21525,71.431259 74.32805,0 0,70.496711 -74.32805,0 0,-70.496711 z").attr(attr);

...然后它工作正常:

things.square.node.setAttribute("id","clicker");

这是为什么?我怎样才能让第一个路径数组起作用?谢谢!

【问题讨论】:

    标签: javascript raphael setattribute


    【解决方案1】:

    我不太了解代码的用途,但我会检查 attr2 是否有效 - 这是两条路径不同的唯一重要之处。
    同时发布错误消息以及发生异常时哪些对象为空会很好。

    【讨论】:

      猜你喜欢
      • 2014-06-09
      • 1970-01-01
      • 2013-08-29
      • 2011-08-07
      • 1970-01-01
      • 2011-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多