【发布时间】:2016-10-29 01:41:47
【问题描述】:
在index-dev.html我加载了一个本地的JavaScript文件:
<script type="text/javascript" src="map.js"></script>
map.js 在结构上(不是字面意思)看起来像这样:
var a2b = {
"a": "My life closed twice before its close—",
"b": "It yet remains to see",
"c": "If Immortality unveil",
"d": "A third event to me",
"e": "So huge, so hopeless to conceive",
"f": "As these that twice befell.",
"g": "Parting is all we know of heaven,",
"h": "And all we need of hell.",
"z": "Emily Dickinson, 1830-1886"
}
我想出了如何将这个对象加载到 Scala.js 中:
val a2b = js.Dynamic.global.a2b
现在a2b 的类型为Dynamic。我要的是Map[String,String]。
我试过这个:
val a2b = js.Dynamic.global.a2b.asInstanceOf[Map[String,String]]
但这没有用。我应该怎么做才能获得Map[String,String]?
【问题讨论】:
标签: scala.js