此scalajs可以正常工作:
console.log(js.eval("numItems").asInstanceOf[Int]) returns the correct value.
但是,此代码始终返回零。有想法吗?
@js.native
@js.annotation.JSGlobalScope
object DOMGlobalScope extends js.Object {
var numItems: Int = js.native
}
console.log(DOMGlobalScope.numItems);