【发布时间】:2015-04-30 03:40:02
【问题描述】:
我需要从 scala.js 调用一个类似的方法:
sigma.classes.graph.addMethod('getNodesCount', function() {
return this.nodesArray.length;
});
这就是在JS中引入库来访问类sigma.classes.graph的内部数组nodesArray的方式。我尝试了类似的东西
trait GraphClassesJS extends js.Object {
def addMethod(name:String,handler: js.Function0[Any]):Unit=js.native
}
我尝试用
打电话s.classes.graph.addMethod("getNodesCount",()=>js.ThisFunction.nodesArray.length)
但我明白了
value nodesArray is not a member of object scala.scalajs.js.ThisFunction
[error] s.classes.graph.addMethod("getNodesCount",()=>js.ThisFunction.nodesArray.length)
我该怎么做? 谢谢 雷纳尔多
【问题讨论】:
标签: scala.js