2013-06-24 27 views
0

我试图通过js.dart与Dart使用paper.js。NoSuchMethodError与dart.js

有很多似乎工作,但我也需要从paper.js的方法importSVG。当我尝试访问js.context.paper.project.importSVG(query("#svg"));时,我得到NoSuchMethodError。这在某种程度上是因为该方法被注入到项目中 - 请参阅下面的paper.js中的代码。

如何从Dart访问importSVG方法?

/* paper.js */ 
new function() { 
    function importSVG(node, clearDefs) { 
      // ... 
    } 

    Item.inject(/** @lends Item# */{ 
      /** 
      * Converts the passed node node into a Paper.js item and adds it to the 
      * children of this item. 
      * 
      * @param {SVGSVGElement} node the SVG DOM node to convert 
      * @return {Item} the converted Paper.js item 
      */ 
      importSVG: function(node) { 
        return this.addChild(importSVG(node, true)); 
      } 
    }); 

    Project.inject(/** @lends Project# */{ 
      /** 
      * Converts the passed node node into a Paper.js item and adds it to the 
      * active layer of this project. 
      * 
      * @param {SVGSVGElement} node the SVG DOM node to convert 
      * @return {Item} the converted Paper.js item 
      */ 
      importSVG: function(node) { 
        this.activate(); 
        return importSVG(node, true); 
      } 
    }); 
}; 
+0

快速浏览一下http://paper.js,似乎你的调用'js.context.paper.project.importSVG(query(“#svg”));'是正确的。你能粘贴整个错误吗? –

+0

感谢您的回答。 “打破异常:NoSuchMethodError:找不到方法:'importSVG'”从js.dart抛出:1038 –

+0

很奇怪。您可以使用_chrome开发人员工具_测试您是否在JavaScript中定义了此方法?在控制台中输入'paper.project.importSVG'。你应该看到类似'function(node){this.activate(); return importSVG(node,true); }' –

回答

0

你的飞镖呼叫似乎是正确的。对这个问题的评论往往表明,在javascript导入/声明paper.project.importSVG中存在问题。

0

这很奇怪。你能告诉我你使用的是什么版本的图书馆吗?它应该在顶部的提交中以及paper.version变量中声明。

相关问题