在ReactDOMBuilder.render中引用div的正确方法是什么?

我一直在转换这个代码:

https://github.com/Kotlin/kotlin-fullstack-sample/blob/master/frontend/src/org/jetbrains/demo/thinkter/HomeView.kt

以我自己的需要,并得到了一个点,在我需要做的渲染方法:

val div = document.getElementById("map") kotlinGoogleMap(div) 

这来自https://blog.frankel.ch/kotlin-front-end-developers/,所以我试图调用的实际线路是这里的第33行https://github.com/nfrankel/kotlin-frontend/blob /master/src/script.kt#L33

有没有从我的HomeView.kt渲染方法做到这一点的好方法?

我能够解决这个componentDidMount:

  override fun componentDidMount() { super.componentDidMount() val div = document.getElementsByClassName("thegmap").item(0) kotlinGoogleMap(div) } 

渲染使得thegmap div:

 override fun ReactDOMBuilder.render() { div { div(classes = "thegmap") { } } } 

后续问题,如果有人正在阅读 – 为什么我不能给这个div一个ID与类?