2
我想从scala-js/test/src/test/scala/scala/scalajs/test/jsinterop/DictionaryTest.scala中的以下代码在Scala中的浏览器中运行.js项目。在Scala.js中的括号存取
import scala.scalajs.js
val obj = js.eval("var dictionaryTest13 =
{ a: 'Scala.js', b: 7357 }; dictionaryTest13;")
val dict = obj.asInstanceOf[js.Dictionary[js.Any]]
var propCount = 0
var propString = ""
for (prop <- js.Dictionary.propertiesOf(dict)) {
propCount += 1
propString += dict(prop)
}
// g.console.log(...)
它给我:了java.lang.RuntimeException:存根
我怎样才能得到这个工作,并利用支架连接,例如通过从js到js的json对象运行,类似于js模式:for(i in obj){obj [i]}?
这样做的目的很简单,就是在未绑定到特定属性的情况下迭代json数据结构。
你用什么Scala.js版本来编译代码? – gzm0
我正在使用0.4-SNAPSHOT构建一个scala-js-example-app的分支,它本身在build.sbt中使用了0.1-SNAPSHOT。 – Michael
你可能想要将它撞到'0.4.1'。我无法重现您的任何问题。但是RTE说“存根”意味着你的编译器与你的库不同步。 ('js.Dictionary.propertiesOf'是一个编译器原语,如果它失败了,编译器不会替换它)。 – gzm0