2017-07-05 8 views
0

私はこのコードを変換してきました。私自身のニーズにReactDOMBuilder.render内のdivを参照する正しい方法は何ですか?

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

をし、私がする必要があるrenderメソッド内のポイントになった:

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レンダリング方法でこれを行う良い方法はありますか?

答えて

0

私はcomponentDidMountでこの問題を解決することができた:

レンダリングがthegmap div要素になり
override fun componentDidMount() { 
     super.componentDidMount() 
     val div = document.getElementsByClassName("thegmap").item(0) 
     kotlinGoogleMap(div) 
    } 

:誰が読んでいる場合

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

は質問をフォローアップ - なぜ私はdivのことを与えることはできませんIDとクラスの違いは?

関連する問題